Skip to content

Commit 324afb5

Browse files
committed
Prepare for auto-publishing to npm on tag builds
1 parent d7ec35f commit 324afb5

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,20 @@ jobs:
290290
run: npm pack
291291
working-directory: packages/std
292292

293-
- name: Get package info
293+
- name: Prepare package upload
294294
# For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit.
295-
run: node .github/workflows/get_package_info.js ${{ github.event.pull_request.head.sha }}
295+
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}
296296

297297
- name: "Upload artifact: npm packages"
298298
uses: actions/upload-artifact@v3
299299
with:
300300
name: npm-packages
301301
path: |
302-
${{ env.rescript_package }}
303-
${{ env.stdlib_package }}
302+
rescript-${{ env.rescript_version }}.tgz
303+
rescript-std-${{ env.rescript_version }}.tgz
304+
305+
outputs:
306+
rescript_version: ${{ env.rescript_version }}
304307

305308
installationTest:
306309
needs: package
@@ -334,7 +337,7 @@ jobs:
334337
path: packages/test
335338

336339
- name: Install ReScript package
337-
run: npm i rescript-11*.tgz
340+
run: npm i rescript-${{ needs.package.outputs.rescript_version }}.tgz
338341
shell: bash
339342
working-directory: packages/test
340343

.github/workflows/get_package_info.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
10+
fs.renameSync(
11+
`rescript-${version}.tgz`,
12+
`rescript-${version}-${commitHashShort}.tgz`
13+
);
14+
fs.renameSync(
15+
`packages/std/rescript-std-${version}.tgz`,
16+
`rescript-std-${version}-${commitHashShort}.tgz`
17+
);
18+
19+
// Pass information to subsequent GitHub actions
20+
fs.appendFileSync(
21+
process.env.GITHUB_ENV,
22+
`rescript_version=${version}-${commitHashShort}${os.EOL}`
23+
);

0 commit comments

Comments
 (0)