Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ac4a6bd

Browse files
committedJun 16, 2024·
Upload package as artifact
1 parent 9ef2b46 commit ac4a6bd

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
 

‎.github/workflows/ci.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,25 @@ jobs:
4646
- name: Build
4747
run: npx rescript
4848

49+
- name: Pack
50+
run: npm pack
51+
4952
- name: Test
5053
env:
5154
CI: 1
5255
shell: bash
5356
run: |
54-
npm pack
5557
npm i -g ./create-rescript-app-*.tgz
5658
npx create-rescript-app
59+
60+
- name: Prepare package upload
61+
if: matrix.os == 'ubuntu-latest'
62+
# For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit.
63+
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}
64+
65+
- name: "Upload artifact: npm package"
66+
if: matrix.os == 'ubuntu-latest'
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: ${{ env.artifact_filename }}
70+
path: ${{ env.artifact_filename }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
);

0 commit comments

Comments
 (0)
Please sign in to comment.