File tree Expand file tree Collapse file tree 3 files changed +56
-13
lines changed Expand file tree Collapse file tree 3 files changed +56
-13
lines changed Original file line number Diff line number Diff line change 9
9
update-version :
10
10
runs-on : ubuntu-latest
11
11
steps :
12
- - uses : actions/checkout@v4
12
+ - name : Checkout repository
13
+ uses : actions/checkout@v4
13
14
14
15
- name : Setup Node.js
15
16
uses : actions/setup-node@v4
@@ -19,25 +20,16 @@ jobs:
19
20
- name : Get latest Lotus version
20
21
id : get-version
21
22
run : |
22
- # Get all releases and find the first one starting with 'v'
23
- RELEASE_INFO=$(curl -s "https://api.github.com/repos/filecoin-project/lotus/releases/latest")
24
-
25
- # Find first tag that starts with 'v' but not 'miner'
26
- TAG_NAME=$(echo "$RELEASE_INFO" | jq -r 'select(.tag_name | startswith("v") and (contains("miner") | not)) | .tag_name')
27
-
28
- # Extract version number (remove 'v' prefix)
29
- LATEST_VERSION=$(echo $TAG_NAME | sed 's/^v//')
30
-
23
+ LATEST_VERSION=$(node scripts/get-latest-lotus-version.js)
31
24
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
32
- echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
33
25
34
26
- name : Run update script
35
- run : |
36
- node update-versions.js ${{ env.LATEST_VERSION }}
27
+ run : node scripts/update-versions.js ${{ env.LATEST_VERSION }}
37
28
38
29
- name : Create Pull Request
39
30
uses : peter-evans/create-pull-request@v5
40
31
with :
32
+ token : ${{ secrets.GITHUB_TOKEN }}
41
33
commit-message : ' Chore: update Lotus version references to ${{ env.LATEST_VERSION }}'
42
34
title : ' Chore: update Lotus version references to ${{ env.LATEST_VERSION }}'
43
35
body : |
Original file line number Diff line number Diff line change
1
+ const https = require ( 'https' ) ;
2
+
3
+ async function getLatestLotusVersion ( ) {
4
+ return new Promise ( ( resolve , reject ) => {
5
+ const options = {
6
+ hostname : 'api.github.com' ,
7
+ path : '/repos/filecoin-project/lotus/releases/latest' ,
8
+ headers : {
9
+ 'User-Agent' : 'Node.js'
10
+ }
11
+ } ;
12
+
13
+ https . get ( options , ( res ) => {
14
+ let data = '' ;
15
+
16
+ res . on ( 'data' , ( chunk ) => {
17
+ data += chunk ;
18
+ } ) ;
19
+
20
+ res . on ( 'end' , ( ) => {
21
+ try {
22
+ const releaseInfo = JSON . parse ( data ) ;
23
+ const tagName = releaseInfo . tag_name ;
24
+
25
+ if ( ! tagName || ! tagName . startsWith ( 'v' ) || tagName . includes ( 'miner' ) ) {
26
+ throw new Error ( 'Could not find a valid tag in the release info' ) ;
27
+ }
28
+
29
+ // Remove 'v' prefix
30
+ const version = tagName . substring ( 1 ) ;
31
+ resolve ( version ) ;
32
+ } catch ( error ) {
33
+ reject ( new Error ( `Failed to parse release info: ${ error . message } ` ) ) ;
34
+ }
35
+ } ) ;
36
+ } ) . on ( 'error' , ( error ) => {
37
+ reject ( new Error ( `Failed to fetch release info: ${ error . message } ` ) ) ;
38
+ } ) ;
39
+ } ) ;
40
+ }
41
+
42
+ if ( require . main === module ) {
43
+ getLatestLotusVersion ( )
44
+ . then ( version => console . log ( version ) )
45
+ . catch ( error => {
46
+ console . error ( error . message ) ;
47
+ process . exit ( 1 ) ;
48
+ } ) ;
49
+ }
50
+
51
+ module . exports = getLatestLotusVersion ;
File renamed without changes.
You can’t perform that action at this time.
0 commit comments