Bump Lotus Version #15
This file contains 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: Bump Lotus Version | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: | |
- main | |
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: | | |
REPO="filecoin-project/lotus" | |
RELEASES_TAGS=$(curl -s "https://api.github.com/repos/${REPO}/releases" | jq -r '.[] | select(.prerelease == false) | .tag_name') | |
get_latest_release() { | |
local TAG_PREFIX=$1 | |
local RELEASES_TAGS_WITH_PREFIX=$(echo "$RELEASES_TAGS" | grep "${TAG_PREFIX}") | |
if [ -z "$RELEASES_TAGS_WITH_PREFIX" ]; then | |
exit 1 | |
fi | |
local LATEST_RELEASE=$(echo "$RELEASES_TAGS_WITH_PREFIX" | sort -V | tail -n 1) | |
if [ -z "$LATEST_RELEASE" ]; then | |
exit 1 | |
fi | |
echo "${LATEST_RELEASE#$TAG_PREFIX}" | |
} | |
latest_lotus=$(get_latest_release "v") | |
latest_miner=$(get_latest_release "miner/v") | |
echo "latest_lotus=$latest_lotus" >> $GITHUB_OUTPUT | |
echo "latest_miner=$latest_miner" >> $GITHUB_OUTPUT | |
- name: Update version.json | |
run: | | |
jq --arg lotus "$LATEST_LOTUS" --arg miner "$LATEST_MINER" '.lotus = $lotus | .miner = $miner' data/version.json > data/version.tmp && mv data/version.tmp data/version.json | |
env: | |
LATEST_LOTUS: ${{ steps.get_release.outputs.latest_lotus }} | |
LATEST_MINER: ${{ steps.get_release.outputs.latest_miner }} | |
- name: Check if changes exist | |
id: git_diff | |
run: | | |
git diff --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT | |
- 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 versions (node=${{ steps.get_release.outputs.latest_lotus }}, miner=${{ steps.get_release.outputs.latest_miner }})" | |
body: "This PR bumps the Lotus versions to node=${{ steps.get_release.outputs.latest_lotus }}, miner=${{ steps.get_release.outputs.latest_miner }}." | |
commit-message: "Bump Lotus versions to node=${{ steps.get_release.outputs.latest_lotus }}, miner=${{ steps.get_release.outputs.latest_miner }}." | |
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
add-paths: | | |
data/version.json |