mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Update workflow
This commit is contained in:
236
.github/workflows/publish.yml
vendored
236
.github/workflows/publish.yml
vendored
@ -1,209 +1,53 @@
|
|||||||
name: Publish
|
name: Publish
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
description: 'Version number'
|
|
||||||
required: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build:
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Remove unnecessary directories
|
- name: Extract version from file
|
||||||
|
id: get_version
|
||||||
run: |
|
run: |
|
||||||
sudo rm -rf /usr/share/dotnet
|
VERSION=$(cut -d "'" -f2 < pwnagotchi/_version.py)
|
||||||
sudo rm -rf /opt/ghc
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
sudo rm -rf /usr/local/share/boost
|
|
||||||
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
|
||||||
|
|
||||||
- name: Check disk space
|
- name: Get latest tag
|
||||||
run: df -BG
|
uses: actions-ecosystem/action-get-latest-tag@v1
|
||||||
|
id: get-latest-tag
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Set LAST_VERSION as an environment variable
|
||||||
uses: actions/checkout@v4
|
run: echo "LAST_VERSION=${{ steps.get-latest-tag.outputs.tag }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Validate tag
|
- name: Generate release notes
|
||||||
id: tag-setter
|
id: generate_release_notes
|
||||||
run: |
|
run: |
|
||||||
TAG=${{ github.event.inputs.version }}
|
COMMITS=$(git log --merges --pretty=format:"* %s" $LAST_VERSION..$VERSION | sed 's/$/\\n/g')
|
||||||
if [[ $TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
CONTRIBUTORS=$(git shortlog -sn $LAST_VERSION..$VERSION | awk '{print "* @" $2}' | sed 's/$/\\n/g')
|
||||||
echo "Tag $TAG is valid."
|
RELEASE_BODY="## What's Changed\n$COMMITS\n\n## New Contributors\n$CONTRIBUTORS\n\n**Full Changelog**: https://github.com/jayofelony/pwnagotchi-torch/compare/$LAST_VERSION...$VERSION"
|
||||||
echo "TAG=$TAG" >> $GITHUB_OUTPUT
|
echo "RELEASE_BODY=$RELEASE_BODY" >> $GITHUB_ENV
|
||||||
else
|
|
||||||
echo "Tag $TAG is not a valid semantic version. Aborting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Install qemu dependencies
|
||||||
uses: actions/setup-python@v5
|
run: sudo apt update && sudo apt install qemu-user-static qemu-utils xz-utils -y
|
||||||
|
|
||||||
|
- name: Build img file
|
||||||
|
run: ls -la .; pwd; make all
|
||||||
|
|
||||||
|
- name: Transfer .img to docker and give permissions
|
||||||
|
run: sudo chown runner:docker "pwnagotchi-rpi-bullseye-armhf.img"
|
||||||
|
|
||||||
|
- name: Compress .img file to an .img.xz
|
||||||
|
run: ls -la .; pwd; xz -z "pwnagotchi-rpi-bullseye-armhf.img"
|
||||||
|
|
||||||
|
- name: Change name of .img.xz to add version
|
||||||
|
run: mv "pwnagotchi-rpi-bullseye-armhf.img.xz" "pwnagotchi-rpi-bullseye-$VERSION-armhf.img.xz"
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
tag_name: ${{ env.VERSION }}
|
||||||
|
name: Pwnagotchi v${{ env.VERSION }}
|
||||||
- name: Install dependencies
|
token: ${{ secrets.TOKEN }}
|
||||||
run: |
|
files: pwnagotchi-rpi-bullseye-${{ env.VERSION }}-armhf.img.xz
|
||||||
sudo apt-get update && sudo apt-get install -y golang libdbus-1-dev curl unzip gettext qemu-utils qemu qemu-user-static binfmt-support
|
body: ${{ env.RELEASE_BODY }}
|
||||||
|
|
||||||
- name: Update QEMU
|
|
||||||
run: |
|
|
||||||
sudo update-binfmts --enable qemu-aarch64
|
|
||||||
sudo update-binfmts --enable qemu-arm
|
|
||||||
echo $(ls /usr/bin/qemu-arm-static)
|
|
||||||
echo $(ls /usr/bin/qemu-aarch64-static)
|
|
||||||
|
|
||||||
- name: Restart binfmt-support
|
|
||||||
run: sudo service binfmt-support restart
|
|
||||||
|
|
||||||
- name: Mount binfmt_misc
|
|
||||||
run: |
|
|
||||||
if ! grep -qs '/proc/sys/fs/binfmt_misc ' /proc/mounts; then
|
|
||||||
echo "Mounting binfmt_misc"
|
|
||||||
sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Restart binfmt-support
|
|
||||||
run: sudo service binfmt-support restart
|
|
||||||
|
|
||||||
- name: Update Languages
|
|
||||||
run: make update_langs
|
|
||||||
|
|
||||||
- name: Compile Languages
|
|
||||||
run: make compile_langs
|
|
||||||
|
|
||||||
- name: Check disk space
|
|
||||||
run: df -BG
|
|
||||||
|
|
||||||
- name: Check qemu-user-static package
|
|
||||||
run: |
|
|
||||||
echo "Checking qemu-user-static package..."
|
|
||||||
dpkg -s qemu-user-static && echo "qemu-user-static is installed." || echo "qemu-user-static is NOT installed."
|
|
||||||
|
|
||||||
- name: Check binfmt-support service
|
|
||||||
run: |
|
|
||||||
echo "Checking binfmt-support service..."
|
|
||||||
service binfmt-support status && echo "binfmt-support service is running." || echo "binfmt-support service is NOT running."
|
|
||||||
|
|
||||||
- name: Check binfmt_misc filesystem
|
|
||||||
run: |
|
|
||||||
echo "Checking binfmt_misc filesystem..."
|
|
||||||
mount | grep binfmt_misc && echo "binfmt_misc is mounted." || echo "binfmt_misc is NOT mounted."
|
|
||||||
echo $(ls /proc/sys/fs/binfmt_misc | grep qemu-aarch64)
|
|
||||||
|
|
||||||
- name: Run Makefile
|
|
||||||
run: make
|
|
||||||
env:
|
|
||||||
PWN_VERSION: ${{ steps.tag-setter.outputs.TAG }}
|
|
||||||
|
|
||||||
- name: PiShrink
|
|
||||||
run: |
|
|
||||||
wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
|
|
||||||
chmod +x pishrink.sh
|
|
||||||
sudo mv pishrink.sh /usr/local/bin/pishrink
|
|
||||||
find /home/runner/work/ -type f -name "*.img" -exec sudo pishrink -aZ {} \;
|
|
||||||
|
|
||||||
- name: Create tag
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const version = "${{ steps.tag-setter.outputs.TAG }}"
|
|
||||||
console.log(`Creating tag ${version}`)
|
|
||||||
await github.rest.git.createRef({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
ref: `refs/tags/${version}`,
|
|
||||||
sha: context.sha
|
|
||||||
})
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const tag = "${{ steps.tag-setter.outputs.TAG }}"
|
|
||||||
console.log(`Creating release with tag: ${tag}`)
|
|
||||||
const release = await github.rest.repos.createRelease({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
tag_name: tag,
|
|
||||||
name: tag,
|
|
||||||
draft: false,
|
|
||||||
prerelease: false,
|
|
||||||
generate_release_notes: true
|
|
||||||
})
|
|
||||||
console.log(`Created release with id: ${release.data.id}`)
|
|
||||||
return release.data.id
|
|
||||||
|
|
||||||
- name: Upload Release Asset
|
|
||||||
id: upload-release-asset
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const release_id = "${{ steps.create_release.outputs.result }}";
|
|
||||||
const asset_content_type = 'application/octet-stream';
|
|
||||||
const distDir = '/home/runner/work/';
|
|
||||||
|
|
||||||
const uploadFile = async (filePath) => {
|
|
||||||
if (fs.lstatSync(filePath).isDirectory()) {
|
|
||||||
const files = fs.readdirSync(filePath);
|
|
||||||
for (const file of files) {
|
|
||||||
await uploadFile(path.join(filePath, file));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Check if the file has a .img.xz extension
|
|
||||||
if (path.extname(filePath) === '.img.xz') {
|
|
||||||
console.log(`Uploading ${filePath}...`);
|
|
||||||
|
|
||||||
const asset_name = path.basename(filePath);
|
|
||||||
const asset_size = fs.statSync(filePath).size;
|
|
||||||
const asset = fs.createReadStream(filePath);
|
|
||||||
|
|
||||||
const response = await github.rest.repos.uploadReleaseAsset({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
release_id: release_id,
|
|
||||||
name: asset_name,
|
|
||||||
data: asset,
|
|
||||||
headers: {
|
|
||||||
'content-type': asset_content_type,
|
|
||||||
'content-length': asset_size
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(`Uploaded ${filePath}: ${response.data.browser_download_url}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await uploadFile(distDir);
|
|
||||||
|
|
||||||
- name: Update Release
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const release_id = "${{ steps.create_release.outputs.result }}"
|
|
||||||
console.log(`Updating release with id: ${release_id}`)
|
|
||||||
github.rest.repos.updateRelease({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
release_id: release_id,
|
|
||||||
tag_name: "${{ steps.tag-setter.outputs.TAG }}",
|
|
||||||
name: "${{ steps.tag-setter.outputs.TAG }}",
|
|
||||||
draft: false,
|
|
||||||
prerelease: false
|
|
||||||
})
|
|
||||||
|
|
||||||
- name: Save environment variable
|
|
||||||
run: echo "${{ steps.tag-setter.outputs.TAG }}" > env_var.txt
|
|
||||||
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: env-var
|
|
||||||
path: env_var.txt
|
|
4
Makefile
4
Makefile
@ -51,12 +51,12 @@ image: clean packer
|
|||||||
bullseye: clean packer
|
bullseye: clean packer
|
||||||
export=LC_ALL=en_GB.utf-8
|
export=LC_ALL=en_GB.utf-8
|
||||||
cd builder && sudo /usr/bin/packer init data/32bit/pwnagotchi.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" data/32bit/pwnagotchi.json.pkr.hcl
|
cd builder && sudo /usr/bin/packer init data/32bit/pwnagotchi.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" data/32bit/pwnagotchi.json.pkr.hcl
|
||||||
cd ~ && sudo pishrink -vaZ pwnagotchi-$(PWN_VERSION)-32bit.img
|
cd ~ && sudo pishrink -vaZ pwnagotchi-32bit.img
|
||||||
|
|
||||||
bookworm: clean packer
|
bookworm: clean packer
|
||||||
export=LC_ALL=en_GB.utf-8
|
export=LC_ALL=en_GB.utf-8
|
||||||
cd builder && sudo /usr/bin/packer init data/64bit/pwnagotchi.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" data/64bit/pwnagotchi.json.pkr.hcl
|
cd builder && sudo /usr/bin/packer init data/64bit/pwnagotchi.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" data/64bit/pwnagotchi.json.pkr.hcl
|
||||||
cd ~ && sudo pishrink -vaZ pwnagotchi-$(PWN_VERSION)-64bit.img
|
cd ~ && sudo pishrink -vaZ pwnagotchi-64bit.img
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
- rm -rf /tmp/packer*
|
- rm -rf /tmp/packer*
|
||||||
|
@ -25,7 +25,7 @@ source "arm" "rpi64-pwnagotchi" {
|
|||||||
file_checksum_type = "sha256"
|
file_checksum_type = "sha256"
|
||||||
file_target_extension = "xz"
|
file_target_extension = "xz"
|
||||||
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
||||||
image_path = "../../../pwnagotchi-${var.pwn_version}-64bit.img"
|
image_path = "../../../pwnagotchi-64bit.img"
|
||||||
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
||||||
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
||||||
image_build_method = "resize"
|
image_build_method = "resize"
|
||||||
@ -55,7 +55,7 @@ source "arm" "rpi32-pwnagotchi" {
|
|||||||
file_checksum_type = "sha256"
|
file_checksum_type = "sha256"
|
||||||
file_target_extension = "xz"
|
file_target_extension = "xz"
|
||||||
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
||||||
image_path = "../../pwnagotchi-${var.pwn_version}-32bit.img"
|
image_path = "../../pwnagotchi-32bit.img"
|
||||||
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
||||||
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
||||||
image_build_method = "resize"
|
image_build_method = "resize"
|
||||||
|
@ -25,7 +25,7 @@ source "arm" "rpi32-pwnagotchi" {
|
|||||||
file_checksum_type = "sha256"
|
file_checksum_type = "sha256"
|
||||||
file_target_extension = "xz"
|
file_target_extension = "xz"
|
||||||
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
||||||
image_path = "../../pwnagotchi-${var.pwn_version}-32bit.img"
|
image_path = "../../pwnagotchi-32bit.img"
|
||||||
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
||||||
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P"
|
||||||
image_build_method = "resize"
|
image_build_method = "resize"
|
||||||
|
@ -25,7 +25,7 @@ source "arm" "rpi64-pwnagotchi" {
|
|||||||
file_checksum_type = "sha256"
|
file_checksum_type = "sha256"
|
||||||
file_target_extension = "xz"
|
file_target_extension = "xz"
|
||||||
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"]
|
||||||
image_path = "../../../pwnagotchi-${var.pwn_version}-64bit.img"
|
image_path = "../../../pwnagotchi-64bit.img"
|
||||||
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
qemu_binary_source_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
||||||
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P"
|
||||||
image_build_method = "resize"
|
image_build_method = "resize"
|
||||||
|
Reference in New Issue
Block a user