File tree 9 files changed +64
-44
lines changed
9 files changed +64
-44
lines changed Original file line number Diff line number Diff line change 60
60
"username": "{{GITHUB_REPOSITORY}}",
61
61
"text": "Release failed: https://github.com/{{GITHUB_REPOSITORY}}/actions/runs/{{GITHUB_RUN_ID}}"
62
62
}
63
+ record_sha :
64
+ name : Record the current build sha on the newly created release
65
+ runs_on : ubuntu-20.04
Original file line number Diff line number Diff line change @@ -10,12 +10,20 @@ jobs:
10
10
name : Upload the Build Shaw
11
11
runs-on : ubuntu-20.04
12
12
steps :
13
- - run : ' [[ ${{github.sha}} == $(curl -L https://github.com/brimdata/zui-insiders/releases/download/v1.2.1-0/sha.txt) ]]'
14
- # - run: echo ${{ github.sha }} > sha.txt
15
- # - name: Upload Sha File To Release
16
- # uses: svenstaro/upload-release-action@v2
17
- # with:
18
- # file: sha.txt
19
- # tag: v1.2.1-0
20
- # repo_name: brimdata/zui-insiders
21
- # repo_token: ${{ secrets.PAT_TOKEN }}
13
+ - name : Create the build_sha file
14
+ run : echo ${{ github.sha }} > build_sha.txt
15
+
16
+ - name : Get Latest Release Tag
17
+ id : latest
18
+ uses :
pozetroninc/[email protected]
19
+ with :
20
+ owner : brimdata
21
+ repo : zui-insiders
22
+
23
+ - name : Upload build_sha File to Release
24
+ uses : svenstaro/upload-release-action@v2
25
+ with :
26
+ file : build_sha.txt
27
+ tag : ${{ steps.latest.outputs.release }}
28
+ repo_name : brimdata/zui-insiders
29
+ repo_token : ${{ secrets.PAT_TOKEN }}
Original file line number Diff line number Diff line change 4
4
"version" : " 0.0.1" ,
5
5
"type" : " commonjs" ,
6
6
"scripts" : {
7
+ "latest-version" : " ts-node src/latest-version" ,
7
8
"inject" : " ts-node src/inject" ,
8
9
"assert-update-needed" : " ts-node src/update-needed"
9
10
},
10
11
"devDependencies" : {
12
+ "@types/node-fetch" : " ^2.6.2" ,
11
13
"fs-extra" : " ^10.1.0" ,
14
+ "node-fetch" : " ^2.6.2" ,
12
15
"octokit" : " 2.1.0" ,
13
16
"semver" : " ^7.3.7"
14
17
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import * as path from 'path' ;
2
2
import * as fs from 'fs-extra' ;
3
3
import * as semver from 'semver' ;
4
- import { getCurrentCommitHash } from './commit' ;
5
4
6
5
const p = ( ...args : unknown [ ] ) => console . log ( '‣' , ...args ) ;
7
6
@@ -43,7 +42,7 @@ export class InsidersPackager {
43
42
? this . stableVersion
44
43
: semver . inc ( this . lastVersion , 'prerelease' ) ;
45
44
46
- return version + '+' + getCurrentCommitHash ( ) ;
45
+ return version ;
47
46
}
48
47
49
48
get strategy ( ) {
Original file line number Diff line number Diff line change
1
+ import { getLatestInsidersVersion } from './latest' ;
2
+
3
+ async function main ( ) {
4
+ const latest = await getLatestInsidersVersion ( ) ;
5
+ console . log ( latest ) ;
6
+ }
7
+
8
+ main ( ) ;
Original file line number Diff line number Diff line change 1
1
import { Octokit } from 'octokit' ;
2
+ import fetch from 'node-fetch' ;
2
3
3
4
const gh = new Octokit ( ) ;
4
5
5
6
export async function getLatestInsidersVersion ( ) {
6
- const release = await gh . rest . repos . getLatestRelease ( {
7
+ const release = await getRelease ( ) ;
8
+ // Remove the v
9
+ return release . data . tag_name . slice ( 1 ) ;
10
+ }
11
+
12
+ export async function getLatestInsidersSha ( ) {
13
+ const release = await getRelease ( ) ;
14
+ const { tag_name } = release . data ;
15
+ const resp = await fetch ( shaUrl ( tag_name ) ) ;
16
+ const sha = await resp . text ( ) ;
17
+ return sha . trim ( ) ;
18
+ }
19
+
20
+ function shaUrl ( tag : string ) {
21
+ return `https://github.com/brimdata/zui-insiders/releases/download/${ tag } /sha.txt` ;
22
+ }
23
+
24
+ function getRelease ( ) {
25
+ return gh . rest . repos . getLatestRelease ( {
7
26
owner : 'brimdata' ,
8
27
repo : 'zui-insiders' ,
9
28
} ) ;
10
-
11
- return release . data . tag_name . slice ( 1 ) ; // Remove the v
12
29
}
Original file line number Diff line number Diff line change 1
- import { getCurrentCommitHash } from './commit' ;
2
- import { getLatestInsidersVersion } from './latest' ;
3
- import * as semver from 'semver' ;
1
+ import { getLatestInsidersSha } from './latest' ;
4
2
5
- function extractCommitFromVersion ( version : string ) {
6
- const parts = semver . parse ( version ) ;
3
+ async function main ( ) {
4
+ const currentSha = process . env [ 'GITHUB_SHA' ] ;
5
+ const releaseSha = await getLatestInsidersSha ( ) ;
7
6
8
- if ( parts && parts . build . length === 1 ) {
9
- return parts . build [ 0 ] ;
10
- } else {
11
- return null ;
12
- }
13
- }
7
+ console . log ( 'Last Release:' , releaseSha ) ;
8
+ console . log ( ' Current:' , currentSha ) ;
14
9
15
- async function main ( ) {
16
- const version = await getLatestInsidersVersion ( ) ;
17
- const head = getCurrentCommitHash ( ) ;
18
- const lastCommit = extractCommitFromVersion ( version ) ;
19
- const updateNeeded = ! ( head === lastCommit ) ;
20
- if ( updateNeeded ) {
21
- console . log ( 'Update needed' ) ;
22
- } else {
23
- console . log ( 'Update not needed' ) ;
10
+ if ( releaseSha . trim ( ) === currentSha ) {
11
+ console . log ( 'No Update Needed' ) ;
24
12
process . exit ( 1 ) ;
13
+ } else {
14
+ console . log ( 'Continue Update' ) ;
25
15
}
26
16
}
27
17
Original file line number Diff line number Diff line change @@ -10807,7 +10807,9 @@ __metadata:
10807
10807
version: 0.0.0-use.local
10808
10808
resolution: "insiders@workspace:apps/insiders"
10809
10809
dependencies:
10810
+ "@types/node-fetch": ^2.6.2
10810
10811
fs-extra: ^10.1.0
10812
+ node-fetch: ^2.6.2
10811
10813
octokit: 2.1.0
10812
10814
semver: ^7.3.7
10813
10815
languageName: unknown
You can’t perform that action at this time.
0 commit comments