From 39bf050d330de61e042c4d79886241d50e14848b Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 9 Jul 2024 10:36:33 +0200 Subject: [PATCH] ci: update version automatically --- .github/workflows/update-version.yml | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/update-version.yml diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 00000000..750cb16c --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,59 @@ +name: Bump Lotus Version + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +permissions: + contents: write + pull-requests: write + +jobs: + bump-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Get the latest release + id: get_release + run: | + latest_release=$(curl -s https://api.github.com/repos/filecoin-project/lotus/releases/latest | jq -r .tag_name) + echo "latest_release=$latest_release" >> $GITHUB_OUTPUT + + - name: Update version.json + run: | + jq --arg version "$LATEST_VERSION" '.lotus = $version' data/version.json > data/version.tmp && mv data/version.tmp data/version.json + env: + LATEST_VERSION: ${{ steps.get_release.outputs.latest_release }} + + - name: Check if changes exist + id: git_diff + run: | + git config --global user.name "github-actions" + git config --global user.email "github-actions@github.com" + git diff --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT + + - name: Commit changes + if: steps.git_diff.outputs.has_changes == 'true' + run: | + git add data/version.json + git commit -m "Bump Lotus version to $LATEST_VERSION" + git push origin HEAD:bump-lotus-version + env: + LATEST_VERSION: ${{ steps.get_release.outputs.latest_release }} + + - name: Create Pull Request + if: steps.git_diff.outputs.has_changes == 'true' + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: bump-lotus-version + title: "Bump Lotus version to ${{ steps.get_release.outputs.latest_release }}" + body: "This PR bumps the Lotus version to ${{ steps.get_release.outputs.latest_release }}." + commit-message: "Bump Lotus version to ${{ steps.get_release.outputs.latest_release }}" + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + add-paths: | + data/version.json