Update Flathub manifest on release #5
Workflow file for this run
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: Update Flathub manifest on release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| update-flathub: | |
| name: "Open PR to Flathub" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout app source at release commit | |
| uses: actions/checkout@v4 | |
| with: | |
| path: source | |
| ref: ${{ github.event.release.tag_name }} | |
| fetch-depth: 0 | |
| - name: Resolve release commit SHA | |
| id: release_sha | |
| working-directory: source | |
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - name: Checkout Flathub manifest repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: flathub/dev.edfloreshz.CosmicTweaks | |
| path: flathub | |
| token: ${{ secrets.FLATHUB_PAT }} | |
| - name: Install flatpak-cargo-generator deps | |
| run: pip3 install aiohttp tomlkit | |
| - name: Generate cargo-sources.json | |
| working-directory: source | |
| run: | | |
| curl -Lo flatpak-cargo-generator.py \ | |
| https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/cargo/flatpak-cargo-generator.py | |
| python3 flatpak-cargo-generator.py Cargo.lock -o cargo-sources.json | |
| - name: Copy cargo-sources.json into Flathub repo | |
| run: cp source/cargo-sources.json flathub/cargo-sources.json | |
| - name: Pin manifest to release commit | |
| working-directory: flathub | |
| env: | |
| RELEASE_COMMIT: ${{ steps.release_sha.outputs.sha }} | |
| run: | | |
| MANIFEST="dev.edfloreshz.CosmicTweaks.json" | |
| jq --arg commit "$RELEASE_COMMIT" \ | |
| '(.modules[] | select(.name == "tweaks") | .sources) |= | |
| map( | |
| if type == "object" and .type == "git" then | |
| .commit = $commit | |
| else . end | |
| ) | |
| ' "$MANIFEST" > "$MANIFEST.tmp" | |
| mv "$MANIFEST.tmp" "$MANIFEST" | |
| - name: Open PR to Flathub | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| path: flathub | |
| token: ${{ secrets.FLATHUB_PAT }} | |
| commit-message: "Update to ${{ github.event.release.tag_name }}" | |
| title: "Update to ${{ github.event.release.tag_name }}" | |
| body: "Automated update from release ${{ github.event.release.html_url }}" | |
| branch: "update-${{ github.event.release.tag_name }}" |