Repository navigation
initial #3
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 Flatpak | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| FLATPAK_ID: com.onclebob.Bob | |
| jobs: | |
| build: | |
| name: Build Flatpak (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm64' || 'ubuntu-latest' }} | |
| strategy: | |
| matrix: | |
| arch: [x86_64, aarch64] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install flatpak-builder | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y flatpak flatpak-builder | |
| - name: Add Flathub repository | |
| run: | | |
| flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | |
| - name: Install Flatpak SDK and runtime | |
| run: | | |
| flatpak install --user -y flathub org.freedesktop.Platform//25.08 org.freedesktop.Sdk//25.08 | |
| flatpak install --user -y flathub org.freedesktop.Sdk.Extension.llvm21//25.08 | |
| - name: Build Flatpak | |
| run: | | |
| flatpak-builder --arch=${{ matrix.arch }} \ | |
| --repo=repo \ | |
| --force-clean \ | |
| --ccache \ | |
| --install-deps-from=flathub \ | |
| build-dir \ | |
| ${{ env.FLATPAK_ID }}.yml | |
| - name: Create Flatpak bundle | |
| run: | | |
| flatpak build-bundle repo \ | |
| ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak \ | |
| ${{ env.FLATPAK_ID }} \ | |
| --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo | |
| - name: Import GPG key | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
| env: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| run: | | |
| echo "$GPG_PRIVATE_KEY" | gpg --batch --import | |
| echo "allow-preset-passphrase" >> ~/.gnupg/gpg-agent.conf | |
| gpg-connect-agent reloadagent /bye | |
| - name: Sign Flatpak bundle | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
| env: | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| run: | | |
| GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2 | head -n1) | |
| echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 \ | |
| --detach-sign --armor \ | |
| --output ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak.sig \ | |
| ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak | |
| - name: Generate checksums | |
| run: | | |
| sha256sum ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak > ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak.sha256 | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: flatpak-${{ matrix.arch }} | |
| path: | | |
| ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak | |
| ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak.sig | |
| ${{ env.FLATPAK_ID }}-${{ matrix.arch }}.flatpak.sha256 | |
| retention-days: 30 | |
| - name: Upload OSTree repository | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ostree-repo-${{ matrix.arch }} | |
| path: repo/ | |
| retention-days: 7 | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release | |
| find artifacts -name "*.flatpak" -exec cp {} release/ \; | |
| find artifacts -name "*.flatpak.sig" -exec cp {} release/ \; | |
| find artifacts -name "*.flatpak.sha256" -exec cp {} release/ \; | |
| ls -lah release/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-repo: | |
| name: Publish OSTree Repository | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Download OSTree repositories | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: ostree-repo-* | |
| path: repos | |
| - name: Merge OSTree repositories | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ostree | |
| ostree init --repo=merged-repo --mode=archive-z2 | |
| for repo in repos/ostree-repo-*/; do | |
| if [ -d "$repo" ]; then | |
| ostree pull-local --repo=merged-repo "$repo" | |
| fi | |
| done | |
| - name: Import GPG key for repo signing | |
| env: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| run: | | |
| echo "$GPG_PRIVATE_KEY" | gpg --batch --import | |
| GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2 | head -n1) | |
| echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV | |
| - name: Sign OSTree repository | |
| env: | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| run: | | |
| ostree summary --repo=merged-repo --update --gpg-sign=${{ env.GPG_KEY_ID }} | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./merged-repo | |
| publish_branch: gh-pages | |
| force_orphan: true |