Skip to content

Lotus version update automation fix #2390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions .github/workflows/update-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -19,25 +20,16 @@ jobs:
- name: Get latest Lotus version
id: get-version
run: |
# Get all releases and find the first one starting with 'v'
RELEASE_INFO=$(curl -s "https://api.github.com/repos/filecoin-project/lotus/releases/latest")

# Find first tag that starts with 'v' but not 'miner'
TAG_NAME=$(echo "$RELEASE_INFO" | jq -r 'select(.tag_name | startswith("v") and (contains("miner") | not)) | .tag_name')

# Extract version number (remove 'v' prefix)
LATEST_VERSION=$(echo $TAG_NAME | sed 's/^v//')

LATEST_VERSION=$(node scripts/get-latest-lotus-version.js)
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 }}
run: node scripts/update-versions.js ${{ env.LATEST_VERSION }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Chore: update Lotus version references to ${{ env.LATEST_VERSION }}'
title: 'Chore: update Lotus version references to ${{ env.LATEST_VERSION }}'
body: |
Expand Down
51 changes: 51 additions & 0 deletions scripts/get-latest-lotus-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const https = require('https');

async function getLatestLotusVersion() {
return new Promise((resolve, reject) => {
const options = {
hostname: 'api.github.com',
path: '/repos/filecoin-project/lotus/releases/latest',
headers: {
'User-Agent': 'Node.js'
}
};

https.get(options, (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
try {
const releaseInfo = JSON.parse(data);
const tagName = releaseInfo.tag_name;

if (!tagName || !tagName.startsWith('v') || tagName.includes('miner')) {
throw new Error('Could not find a valid tag in the release info');
}

// Remove 'v' prefix
const version = tagName.substring(1);
resolve(version);
} catch (error) {
reject(new Error(`Failed to parse release info: ${error.message}`));
}
});
}).on('error', (error) => {
reject(new Error(`Failed to fetch release info: ${error.message}`));
});
});
}

if (require.main === module) {
getLatestLotusVersion()
.then(version => console.log(version))
.catch(error => {
console.error(error.message);
process.exit(1);
});
}

module.exports = getLatestLotusVersion;
File renamed without changes.