Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c1a61d

Browse files
authored
Upload package as artifact (#65)
1 parent 9ef2b46 commit 8c1a61d

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

‎.github/workflows/ci.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,42 @@ concurrency:
1818

1919
jobs:
2020
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+
2157
strategy:
2258
fail-fast: false
2359
matrix:
@@ -40,17 +76,15 @@ jobs:
4076
with:
4177
node-version: 18
4278

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 }}
4883

4984
- name: Test
5085
env:
5186
CI: 1
5287
shell: bash
5388
run: |
54-
npm pack
55-
npm i -g ./create-rescript-app-*.tgz
89+
npm i -g ${{ needs.build.outputs.artifact_filename }}
5690
npx create-rescript-app
Lines changed: 17 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /