File tree 2 files changed +58
-7
lines changed
2 files changed +58
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,42 @@ concurrency:
18
18
19
19
jobs :
20
20
build :
21
+ runs-on : ubuntu-latest
22
+
23
+ steps :
24
+ - name : Checkout
25
+ uses : actions/checkout@v4
26
+
27
+ - name : Use Node.js
28
+ uses : actions/setup-node@v4
29
+ with :
30
+ node-version : 18
31
+
32
+ - name : NPM install
33
+ run : npm ci
34
+
35
+ - name : Build
36
+ run : npx rescript
37
+
38
+ - name : Pack
39
+ run : npm pack
40
+
41
+ - name : Prepare package upload
42
+ # For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit.
43
+ run : node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}
44
+
45
+ - name : " Upload artifact: npm package"
46
+ uses : actions/upload-artifact@v4
47
+ with :
48
+ name : ${{ env.artifact_filename }}
49
+ path : ${{ env.artifact_filename }}
50
+
51
+ outputs :
52
+ artifact_filename : ${{ env.artifact_filename }}
53
+
54
+ test :
55
+ needs : build
56
+
21
57
strategy :
22
58
fail-fast : false
23
59
matrix :
@@ -40,17 +76,15 @@ jobs:
40
76
with :
41
77
node-version : 18
42
78
43
- - name : NPM install
44
- run : npm ci
45
-
46
- - name : Build
47
- run : npx rescript
79
+ - name : Download artifacts
80
+ uses : actions/download-artifact@v4
81
+ with :
82
+ name : ${{ needs.build.outputs.artifact_filename }}
48
83
49
84
- name : Test
50
85
env :
51
86
CI : 1
52
87
shell : bash
53
88
run : |
54
- npm pack
55
- npm i -g ./create-rescript-app-*.tgz
89
+ npm i -g ${{ needs.build.outputs.artifact_filename }}
56
90
npx create-rescript-app
Original file line number Diff line number Diff line change
1
+ const fs = require ( "fs" ) ;
2
+ const os = require ( "os" ) ;
3
+
4
+ const packageSpec = JSON . parse ( fs . readFileSync ( "./package.json" , "utf8" ) ) ;
5
+ const { version } = packageSpec ;
6
+
7
+ const commitHash = process . argv [ 2 ] || process . env . GITHUB_SHA ;
8
+ const commitHashShort = commitHash . substring ( 0 , 7 ) ;
9
+ const artifactFilename = `create-rescript-app-${ version } -${ commitHashShort } .tgz` ;
10
+
11
+ fs . renameSync ( `create-rescript-app-${ version } .tgz` , artifactFilename ) ;
12
+
13
+ // Pass information to subsequent GitHub actions
14
+ fs . appendFileSync (
15
+ process . env . GITHUB_ENV ,
16
+ `artifact_filename=${ artifactFilename } ${ os . EOL } `
17
+ ) ;
You can’t perform that action at this time.
0 commit comments