release-event #91
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: Flatpak Build and Deploy | |
| on: | |
| # push: | |
| # branches: | |
| # - main | |
| # pull_request: | |
| workflow_dispatch: # allow manual trigger | |
| repository_dispatch: | |
| types: [release-event] | |
| env: | |
| APP_ID: xyz.fontra.FontraPak | |
| RUNTIME_REPO: "https://flathub.org/repo/flathub.flatpakrepo" | |
| jobs: | |
| update-release: | |
| name: Update to Latest FontraPak Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Get latest release info | |
| id: latest-release | |
| run: | | |
| RELEASE_DATA=$(curl -s https://api.github.com/repos/fontra/fontra-pak/releases/latest) | |
| VERSION=$(echo "$RELEASE_DATA" | jq -r .tag_name) | |
| ASSET_URL=$(echo "$RELEASE_DATA" | jq -r '.assets[] | select(.name=="FontraPak-Ubuntu.tgz") | .browser_download_url') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "asset_url=$ASSET_URL" >> $GITHUB_OUTPUT | |
| - name: Download and calculate SHA256 | |
| id: calculate-sha | |
| run: | | |
| curl -L -o FontraPak-Ubuntu.tgz "${{ steps.latest-release.outputs.asset_url }}" | |
| SHA256=$(sha256sum FontraPak-Ubuntu.tgz | awk '{print $1}') | |
| echo "sha256=$SHA256" >> $GITHUB_OUTPUT | |
| rm FontraPak-Ubuntu.tgz | |
| - name: Update manifest file | |
| run: | | |
| VERSION="${{ steps.latest-release.outputs.version }}" | |
| SHA256="${{ steps.calculate-sha.outputs.sha256 }}" | |
| sed -i "s|url: https://github.com/fontra/fontra-pak/releases/download/[^/]*/FontraPak-Ubuntu.tgz|url: https://github.com/fontra/fontra-pak/releases/download/${VERSION}/FontraPak-Ubuntu.tgz|" ${{ env.APP_ID }}.yml | |
| sed -i "s|sha256: .*|sha256: ${SHA256}|" ${{ env.APP_ID }}.yml | |
| - name: Update metainfo.xml with new release | |
| run: | | |
| VERSION="${{ steps.latest-release.outputs.version }}" | |
| VERSION_CLEAN=$(echo $VERSION | sed 's/^v//') | |
| DATE=$(date +%Y-%m-%d) | |
| sed -i "/<releases>/a\ <release version=\"${VERSION_CLEAN}\" date=\"${DATE}\"/>" ${{ env.APP_ID }}.metainfo.xml | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| if git diff --quiet; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git add ${{ env.APP_ID }}.yml ${{ env.APP_ID }}.metainfo.xml | |
| git commit -m "chore: update to FontraPak ${{ steps.latest-release.outputs.version }}" | |
| git push | |
| flatpak: | |
| name: Build Flatpak | |
| runs-on: ubuntu-latest | |
| needs: update-release | |
| container: | |
| image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.08 | |
| options: --privileged | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Import GPG key | |
| id: import_gpg | |
| uses: crazy-max/ghaction-import-gpg@v7 | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| trust_level: 5 | |
| - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 | |
| with: | |
| manifest-path: ${{ env.APP_ID }}.yml | |
| bundle: ${{ env.APP_ID }}.flatpak | |
| branch: ${{ github.ref_name }} | |
| gpg-sign: ${{ steps.import_gpg.outputs.keyid }} | |
| upload-artifact: true | |
| cache-key: flatpak-builder-${{ github.sha }} | |
| - name: Generate repository summary | |
| run: | | |
| flatpak build-update-repo --gpg-sign=${{ steps.import_gpg.outputs.keyid }} --generate-static-deltas --prune repo/ | |
| - name: Upload OSTree repository | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: flatpak-repo | |
| path: repo/ | |
| pages: | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: flatpak | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download OSTree repository | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: flatpak-repo | |
| path: repo | |
| - name: Prepare files for GitHub Pages | |
| run: | | |
| mkdir -p public | |
| cp -r repo/* public/ | |
| cp ${{ env.APP_ID }}.flatpakref public/ || true | |
| - name: Upload pages artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: public | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |