Skip to content

Commit

Permalink
Upload package as artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Jun 16, 2024
1 parent 9ef2b46 commit c9bb0fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,24 @@ jobs:
- name: Build
run: npx rescript

- name: Pack
run: npm pack

- name: Test
env:
CI: 1
shell: bash
run: |
npm pack
npm i -g ./create-rescript-app-*.tgz
npx create-rescript-app
- name: Prepare package upload
# For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit.
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}

- name: "Upload artifact: npm package"
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: ${{env.artifact_filename}}
path: ${{env.artifact_filename}}
17 changes: 17 additions & 0 deletions .github/workflows/prepare_package_upload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require("fs");
const os = require("os");

const packageSpec = JSON.parse(fs.readFileSync("./package.json", "utf8"));
const { version } = packageSpec;

const commitHash = process.argv[2] || process.env.GITHUB_SHA;
const commitHashShort = commitHash.substring(0, 7);
const artifactFilename = `create-rescript-app-${version}-${commitHashShort}.tgz`;

fs.renameSync(`create-rescript-app-${version}.tgz`, artifactFilename);

// Pass information to subsequent GitHub actions
fs.appendFileSync(
process.env.GITHUB_ENV,
`artifact_filename=${artifact_filename}${os.EOL}`
);

0 comments on commit c9bb0fe

Please sign in to comment.