Add automatic version updater script and github action #1
Workflow file for this run
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: Update Lotus Version | |
on: | |
schedule: | |
- cron: '0 0 * * 1' # Runs at 00:00 every Monday | |
workflow_dispatch: # Allows manual trigger | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
update-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Get latest Lotus version | |
id: get-version | |
run: | | |
# Get the latest release info | |
RELEASE_INFO=$(curl -s https://api.github.com/repos/filecoin-project/lotus/releases/latest) | |
# Extract the tag name | |
TAG_NAME=$(echo "$RELEASE_INFO" | jq -r .tag_name) | |
# Handle different tag formats | |
if [[ $TAG_NAME == *"miner"* ]]; then | |
# For miner tags, extract everything after 'v' | |
LATEST_VERSION=$(echo $TAG_NAME | sed -E 's/.*v([^/]*).*/\1/') | |
else | |
# For standard tags (e.g., v1.31.1) | |
LATEST_VERSION=$(echo $TAG_NAME | sed 's/^v//') | |
fi | |
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV | |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
- name: Run update script | |
run: | | |
node update-versions.js ${{ env.LATEST_VERSION }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: 'chore: update Lotus version references to ${{ env.LATEST_VERSION }}' | |
title: 'chore: update Lotus version references to ${{ env.LATEST_VERSION }}' | |
body: | | |
Automated PR to update Lotus version references to ${{ env.LATEST_VERSION }} | |
Original tag: ${{ env.TAG_NAME }} | |
Extracted version: ${{ env.LATEST_VERSION }} | |
This PR updates all references of: | |
- `lotus-X.X.X` | |
- Previous lotus version numbers | |
to `lotus-${{ env.LATEST_VERSION }}` | |
This PR was automatically generated by GitHub Actions. | |
branch: update-lotus-version | |
delete-branch: true |