From d55d87e6bdc1b9910892d3f93130a4c89e57f441 Mon Sep 17 00:00:00 2001 From: Dan Kluser Date: Thu, 14 May 2026 12:45:22 +0200 Subject: [PATCH] move actions to image repo --- .github/workflows/build-image.yml | 194 +++++++++++++++++++++++++++ .github/workflows/test-uploads.yml | 173 ++++++++++++++++++++++++ .github/workflows/trigger-builds.yml | 14 +- 3 files changed, 368 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/build-image.yml create mode 100644 .github/workflows/test-uploads.yml diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..d5887c5 --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,194 @@ +name: Build Image +run-name: Build Image (${{ inputs.distro || 'all' }}) + +on: + workflow_dispatch: + inputs: + distro: + description: 'Distribution' + default: 'ubuntu2604' + type: choice + options: [all, ubuntu2604, arch, cachyos, alpine] + workflow_call: + inputs: + distro: + type: string + default: 'ubuntu2604' + secrets: + REMOTE_SSH_KEY: + required: true + REMOTE_SSH_CONFIG: + required: true + REMOTE_SSH_KNOWN_HOSTS: + required: true + R2_ACCESS_KEY_ID: + required: true + R2_SECRET_ACCESS_KEY: + required: true + R2_ENDPOINT: + required: true + R2_BUCKET: + required: true + +jobs: + matrix: + runs-on: self-hosted + outputs: + distros: ${{ steps.set.outputs.distros }} + steps: + - id: set + run: | + INPUT="${{ inputs.distro || 'ubuntu2604' }}" + if [ "$INPUT" = "all" ]; then + echo 'distros=["ubuntu2604","arch","cachyos","alpine"]' >> "$GITHUB_OUTPUT" + else + echo "distros=[\"$INPUT\"]" >> "$GITHUB_OUTPUT" + fi + + build: + needs: matrix + runs-on: self-hosted + timeout-minutes: 240 + permissions: + contents: write + + strategy: + fail-fast: false + max-parallel: 1 + matrix: + distro: ${{ fromJson(needs.matrix.outputs.distros) }} + + env: + CCACHE_DIR: /home/opc/ccache + + steps: + - name: Checkout image builder + uses: actions/checkout@v6 + with: + repository: ps5-linux/ps5-linux-image + path: image + ref: main + + - name: Build ${{ matrix.distro }} image + run: | + bash image/build_image.sh --distro "${{ matrix.distro }}" + + - name: Set version info + id: version + run: | + psha=$(git -C image/work/ps5-linux-patches rev-parse --short HEAD 2>/dev/null || echo "unknown") + kver=$(cat image/linux-bin/VERSION 2>/dev/null || echo "unknown") + ts=$(date -u +%Y%m%d-%H%M%S) + echo "psha=$psha" >> "$GITHUB_OUTPUT" + echo "kver=$kver" >> "$GITHUB_OUTPUT" + echo "ts=$ts" >> "$GITHUB_OUTPUT" + + - name: Report + run: | + ls -lh image/output/*.img + sha256sum image/output/*.img + + - name: Compress image + run: | + xz -T0 -9 -c image/output/ps5-${{ matrix.distro }}.img \ + > image/output/ps5-${{ matrix.distro }}.img.xz + + - name: Upload to R2 + env: + RCLONE_CONFIG_R2_TYPE: s3 + RCLONE_CONFIG_R2_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + RCLONE_CONFIG_R2_NO_CHECK_BUCKET: true + run: | + rclone copyto image/output/ps5-${{ matrix.distro }}.img.xz \ + "r2:${{ secrets.R2_BUCKET }}/ps5-${{ matrix.distro }}.img.xz" + + - name: Save build metadata + run: | + mkdir -p meta + sha256sum image/output/ps5-${{ matrix.distro }}.img.xz \ + | sed 's|image/output/||' > meta/${{ matrix.distro }}.sha256 + echo "${{ steps.version.outputs.kver }}" > meta/kver + echo "${{ steps.version.outputs.psha }}" > meta/psha + echo "${{ steps.version.outputs.ts }}" > meta/ts + + - name: Upload build metadata + uses: actions/upload-artifact@v6 + with: + name: meta-${{ matrix.distro }} + path: meta/ + retention-days: 1 + + - name: Upload to remote + env: + SSH_KEY: ${{ secrets.REMOTE_SSH_KEY }} + SSH_CONFIG: ${{ secrets.REMOTE_SSH_CONFIG }} + SSH_KNOWN_HOSTS: ${{ secrets.REMOTE_SSH_KNOWN_HOSTS }} + run: | + DIR=$(mktemp -d) + echo "$SSH_KEY" > "$DIR/key" + chmod 600 "$DIR/key" + echo "$SSH_CONFIG" > "$DIR/config" + sed -i "s|~/.ssh/remote_key|$DIR/key|" "$DIR/config" + echo "$SSH_KNOWN_HOSTS" > "$DIR/known_hosts" + SSH="ssh -F $DIR/config -o UserKnownHostsFile=$DIR/known_hosts" + SCP="scp -F $DIR/config -o UserKnownHostsFile=$DIR/known_hosts" + DEST="image-${{ matrix.distro }}-${{ steps.version.outputs.ts }}" + $SSH remote mkdir -p "./$DEST" + $SCP image/output/*.img.xz "remote:./$DEST/" + $SSH remote 'ls -dt image-${{ matrix.distro }}-*/ | tail -n +5 | xargs rm -rf' || true + rm -rf "$DIR" + + release: + needs: build + runs-on: self-hosted + permissions: + contents: write + steps: + - name: Download build metadata + uses: actions/download-artifact@v6 + with: + pattern: meta-* + path: meta + merge-multiple: true + + - name: Prepare release body + id: body + run: | + KVER=$(cat meta/kver) + PSHA=$(cat meta/psha) + TS=$(cat meta/ts) + SUMS=$(cat meta/*.sha256) + + { + echo 'text<> "$GITHUB_OUTPUT" + + - name: Create or update release + uses: softprops/action-gh-release@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: latest + name: PS5 Linux Image (latest) + body: ${{ steps.body.outputs.text }} + make_latest: true diff --git a/.github/workflows/test-uploads.yml b/.github/workflows/test-uploads.yml new file mode 100644 index 0000000..000c8fb --- /dev/null +++ b/.github/workflows/test-uploads.yml @@ -0,0 +1,173 @@ +name: test uploads + +on: + workflow_dispatch: + +jobs: + matrix: + runs-on: self-hosted + outputs: + distros: ${{ steps.set.outputs.distros }} + steps: + - id: set + run: echo 'distros=["ubuntu2604","arch","cachyos","alpine"]' >> "$GITHUB_OUTPUT" + + build: + needs: matrix + runs-on: self-hosted + timeout-minutes: 10 + + strategy: + fail-fast: false + max-parallel: 1 + matrix: + distro: ${{ fromJson(needs.matrix.outputs.distros) }} + + steps: + - name: Reset workspace + run: sudo rm -rf ./* + + - name: Create fake image + run: | + mkdir -p image/output + dd if=/dev/urandom of=image/output/ps5-${{ matrix.distro }}.img bs=1M count=8 + + - name: Compress image + run: | + xz -T0 -1 -c image/output/ps5-${{ matrix.distro }}.img \ + > image/output/ps5-${{ matrix.distro }}.img.xz + + - name: Upload to R2 + env: + RCLONE_CONFIG_R2_TYPE: s3 + RCLONE_CONFIG_R2_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + RCLONE_CONFIG_R2_NO_CHECK_BUCKET: true + run: | + rclone copyto image/output/ps5-${{ matrix.distro }}.img.xz \ + "r2:${{ secrets.R2_BUCKET }}/test-${{ matrix.distro }}.img.xz" -v + + - name: Save build metadata + run: | + mkdir -p meta + sha256sum image/output/ps5-${{ matrix.distro }}.img.xz \ + | sed 's|image/output/||' > meta/${{ matrix.distro }}.sha256 + echo "6.x.y-test" > meta/kver + echo "abc1234" > meta/psha + date -u +%Y%m%d-%H%M%S > meta/ts + + - name: Upload build metadata + uses: actions/upload-artifact@v6 + with: + name: meta-${{ matrix.distro }} + path: meta/ + retention-days: 1 + + - name: Upload to remote + env: + SSH_KEY: ${{ secrets.REMOTE_SSH_KEY }} + SSH_CONFIG: ${{ secrets.REMOTE_SSH_CONFIG }} + SSH_KNOWN_HOSTS: ${{ secrets.REMOTE_SSH_KNOWN_HOSTS }} + run: | + DIR=$(mktemp -d) + echo "$SSH_KEY" > "$DIR/key" + chmod 600 "$DIR/key" + echo "$SSH_CONFIG" > "$DIR/config" + sed -i "s|~/.ssh/remote_key|$DIR/key|" "$DIR/config" + echo "$SSH_KNOWN_HOSTS" > "$DIR/known_hosts" + SSH="ssh -F $DIR/config -o UserKnownHostsFile=$DIR/known_hosts" + SCP="scp -F $DIR/config -o UserKnownHostsFile=$DIR/known_hosts" + $SSH remote mkdir -p ./test-upload + $SCP image/output/ps5-${{ matrix.distro }}.img.xz "remote:./test-upload/" + rm -rf "$DIR" + + - name: Cleanup + if: always() + run: rm -rf image/output meta + + release: + needs: build + runs-on: self-hosted + steps: + - name: Download build metadata + uses: actions/download-artifact@v6 + with: + pattern: meta-* + path: meta + merge-multiple: true + + - name: Prepare release body + id: body + run: | + KVER=$(cat meta/kver) + PSHA=$(cat meta/psha) + TS=$(cat meta/ts) + SUMS=$(cat meta/*.sha256) + + { + echo 'text<> "$GITHUB_OUTPUT" + + - name: Verify release body + run: | + echo "=== Release body ===" + cat <<'EOF' + ${{ steps.body.outputs.text }} + EOF + echo "" + echo "=== All checksums ===" + cat meta/*.sha256 + + cleanup-remote: + needs: release + runs-on: self-hosted + if: always() + steps: + - name: Clean up R2 test files + env: + RCLONE_CONFIG_R2_TYPE: s3 + RCLONE_CONFIG_R2_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + RCLONE_CONFIG_R2_NO_CHECK_BUCKET: true + run: | + for d in ubuntu2604 arch cachyos alpine; do + rclone delete "r2:${{ secrets.R2_BUCKET }}/test-${d}.img.xz" -v || true + done + + - name: Clean up remote test files + env: + SSH_KEY: ${{ secrets.REMOTE_SSH_KEY }} + SSH_CONFIG: ${{ secrets.REMOTE_SSH_CONFIG }} + SSH_KNOWN_HOSTS: ${{ secrets.REMOTE_SSH_KNOWN_HOSTS }} + run: | + DIR=$(mktemp -d) + echo "$SSH_KEY" > "$DIR/key" + chmod 600 "$DIR/key" + echo "$SSH_CONFIG" > "$DIR/config" + sed -i "s|~/.ssh/remote_key|$DIR/key|" "$DIR/config" + echo "$SSH_KNOWN_HOSTS" > "$DIR/known_hosts" + SSH="ssh -F $DIR/config -o UserKnownHostsFile=$DIR/known_hosts" + $SSH remote rm -rf ./test-upload + rm -rf "$DIR" diff --git a/.github/workflows/trigger-builds.yml b/.github/workflows/trigger-builds.yml index f6f6a09..27cf704 100644 --- a/.github/workflows/trigger-builds.yml +++ b/.github/workflows/trigger-builds.yml @@ -6,24 +6,13 @@ on: branches: [main] jobs: - kernel: - permissions: - contents: write - uses: ps5-linux/ps5-linux-updates/.github/workflows/build-kernel.yml@main - secrets: - DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} - REMOTE_SSH_KEY: ${{ secrets.REMOTE_SSH_KEY }} - REMOTE_SSH_CONFIG: ${{ secrets.REMOTE_SSH_CONFIG }} - REMOTE_SSH_KNOWN_HOSTS: ${{ secrets.REMOTE_SSH_KNOWN_HOSTS }} - image: permissions: contents: write - uses: ps5-linux/ps5-linux-updates/.github/workflows/build-image.yml@main + uses: ./.github/workflows/build-image.yml with: distro: all secrets: - DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} REMOTE_SSH_KEY: ${{ secrets.REMOTE_SSH_KEY }} REMOTE_SSH_CONFIG: ${{ secrets.REMOTE_SSH_CONFIG }} REMOTE_SSH_KNOWN_HOSTS: ${{ secrets.REMOTE_SSH_KNOWN_HOSTS }} @@ -31,4 +20,3 @@ jobs: R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} R2_BUCKET: ${{ secrets.R2_BUCKET }} -