Update Flatpak YAML to use latest version of ASIMOV CLI #86
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 Flatpak YAML to use latest version of ASIMOV CLI | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # At 02:00 every night – https://crontab.guru/#0_2_*_*_* | |
| - cron: "0 2 * * *" | |
| jobs: | |
| updateFlatpak: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Git user | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Update Flatpak YAML | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| FLATPAK_YAML="flatpak/so.asimov.cli.yaml" | |
| LATEST_VERSION="$(curl -s https://api.github.com/repos/asimov-platform/asimov-cli/releases/latest | jq -r .tag_name)" | |
| sed -i "s|https://github.com/asimov-platform/asimov-cli/releases/download/[^/]*|https://github.com/asimov-platform/asimov-cli/releases/download/${LATEST_VERSION}|g" "$FLATPAK_YAML" | |
| x86_64_hex="$(curl -sL "https://github.com/asimov-platform/asimov-cli/releases/download/${LATEST_VERSION}/asimov-linux-x86-gnu.gz.sha256" | cut -d ' ' -f1)" | |
| sed -i -E "/asimov-linux-x86-gnu.gz/{N;s/(sha256: \").*(\".*)/\1${x86_64_hex}\2/}" "$FLATPAK_YAML" | |
| aarch64_hex="$(curl -sL "https://github.com/asimov-platform/asimov-cli/releases/download/${LATEST_VERSION}/asimov-linux-arm-gnu.gz.sha256" | cut -d ' ' -f1)" | |
| sed -i -E "/asimov-linux-arm-gnu.gz/{N;s/(sha256: \").*(\".*)/\1${aarch64_hex}\2/}" "$FLATPAK_YAML" | |
| if ! git diff --exit-code "$FLATPAK_YAML"; then | |
| git add "$FLATPAK_YAML" | |
| git commit -m "Update Flatpak YAML to ${LATEST_VERSION}" | |
| git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" HEAD:${{ github.ref }} | |
| fi |