Upgrade GitHub Actions to Node.js 24 compatible versions and add single build workflow #125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release Droidspaces RootFS | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| update_json_only: | |
| description: 'Only update rootfs.json (skip build & release)' | |
| type: boolean | |
| default: false | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| setup: | |
| if: ${{ github.event.inputs.update_json_only != 'true' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| templates: ${{ steps.find-templates.outputs.templates }} | |
| build_id: ${{ steps.prep.outputs.build_id }} | |
| build_date: ${{ steps.prep.outputs.build_date }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| - name: Find Build Templates | |
| id: find-templates | |
| run: | | |
| # Find all *.Dockerfile files, extract names, and format as JSON array | |
| TEMPLATES=$(ls *.Dockerfile | sed 's/\.Dockerfile//' | jq -R -s -c 'split("\n")[:-1]') | |
| echo "templates=$TEMPLATES" >> $GITHUB_OUTPUT | |
| echo "Detected templates: $TEMPLATES" | |
| - name: Prepare Build Metadata | |
| id: prep | |
| run: | | |
| BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S') | |
| BUILD_ID="v$(date +'%Y%m%d-%H%M%S')" | |
| echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_OUTPUT | |
| echo "BUILD_ID=$BUILD_ID" >> $GITHUB_OUTPUT | |
| echo "Build ID: $BUILD_ID" | |
| build: | |
| if: ${{ github.event.inputs.update_json_only != 'true' }} | |
| needs: setup | |
| runs-on: ubuntu-24.04-arm | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| template: ${{ fromJson(needs.setup.outputs.templates) }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| - name: Build RootFS (${{ matrix.template }}) | |
| run: | | |
| chmod +x build_rootfs-native.sh | |
| # Native build without QEMU overhead | |
| ./build_rootfs-native.sh -i "${{ matrix.template }}.Dockerfile" -v "${{ needs.setup.outputs.build_id }}" | |
| - name: Upload Build Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.template }}-rootfs | |
| path: "*.tar.xz" | |
| retention-days: 1 | |
| build-nixos: | |
| if: ${{ github.event.inputs.update_json_only != 'true' }} | |
| needs: setup | |
| runs-on: ubuntu-24.04-arm | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: NixOS-Minimal-Systemd-latest-Kernel-5.10-and-up | |
| attr: nixosDroidspacesTarballs.aarch64-linux.minimal | |
| - name: NixOS-Minimal-Systemd-v257.9 | |
| attr: nixosDroidspacesTarballs.aarch64-linux.minimal-with-systemd-v257 | |
| - name: NixOS-Minimal-Finix-Experimental | |
| attr: finixDroidspacesTarballs.aarch64-linux.experimental | |
| steps: | |
| - name: Install Nix | |
| uses: DeterminateSystems/nix-installer-action@v16 | |
| - name: Build ${{ matrix.name }} RootFS | |
| run: | | |
| nix build github:ravindu644/Droidspaces-OSS#${{ matrix.attr }} | |
| - name: Package artifact | |
| run: | | |
| DATE=$(date +%Y%m%d) | |
| TARBALL=$(find result/tarball -name "*.tar.xz" | head -1) | |
| FINAL="${{ matrix.name }}-Droidspaces-rootfs-aarch64-${DATE}-${{ needs.setup.outputs.build_id }}.tar.xz" | |
| cp "$TARBALL" "$FINAL" | |
| - name: Upload Build Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.name }}-rootfs | |
| path: "*.tar.xz" | |
| retention-days: 1 | |
| release: | |
| if: ${{ github.event.inputs.update_json_only != 'true' }} | |
| needs: [setup, build, build-nixos] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| - name: Download All Artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: "*-rootfs" | |
| merge-multiple: true | |
| - name: Create Unified Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: ${{ needs.setup.outputs.build_id }} | |
| name: "Droidspaces RootFS ${{ needs.setup.outputs.build_id }}" | |
| files: "*.tar.xz" | |
| body: | | |
| Automated Droidspaces RootFS Multi-Build | |
| Built on: ${{ needs.setup.outputs.build_date }} | |
| Build ID: ${{ needs.setup.outputs.build_id }} | |
| Included Templates: | |
| ${{ join(fromJson(needs.setup.outputs.templates), ', ') }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update rootfs.json Registry | |
| run: | | |
| python3 scripts/update_rootfs_json.py . | |
| - name: Commit and Push rootfs.json | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add rootfs.json | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: update rootfs.json for release ${{ needs.setup.outputs.build_id }}" | |
| git pull --rebase origin main | |
| git push origin HEAD:main | |
| else | |
| echo "No changes in rootfs.json to push." | |
| fi | |
| update-json: | |
| needs: [release] | |
| if: always() && (needs.release.result == 'success' || github.event.inputs.update_json_only == 'true') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| - name: Update rootfs.json Registry | |
| run: python3 scripts/update_rootfs_json.py . | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Commit and Push rootfs.json | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add rootfs.json | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: update rootfs.json" | |
| git pull --rebase origin main | |
| git push origin HEAD:main | |
| else | |
| echo "No changes in rootfs.json to push." | |
| fi |