From d022931543e81d4ab8ce2fcdc1ccb902c3829bea Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Mon, 22 Jul 2024 07:37:02 -0700 Subject: [PATCH 1/5] use new release.yml --- .github/workflows/release.yml | 49 ++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 009ae51..1483e2b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ -name: Release +name: new-build on: + workflow_dispatch: push: tags: ['v[0-9]+.[0-9]+.[0-9]+'] @@ -15,12 +16,37 @@ permissions: contents: read jobs: - build: + build-linux: + name: Build linux versions + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 22.5.1 + - name: Install dependencies + run: npm ci --ignore-scripts + # build each image inline so the matrix doesn't checkout, install, install each time. + - name: Build alpine + run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/contrast-security-oss/alpine + - name: Build centos7 + run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/contrast-security-oss/centos7 + - name: Build linux-arm64 + run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/contrast-security-oss/linux-arm64 + # now upload what was built + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: prebuilds-linux + path: prebuilds/ + + build-macos-windows: strategy: matrix: include: - - os: ubuntu-latest - build-group: linux - os: macos-latest build-group: darwin - os: windows-latest @@ -34,13 +60,8 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: 22 - - name: Update npm - run: npm install -g npm@10 - # new versions of python don't include distutils. setuptools provides it. - - name: Install setuptools - run: pip install setuptools - - name: Install + node-version: 22.5.1 + - name: Install dependencies run: npm ci --ignore-scripts - name: Build run: npm run build:${{ matrix.build-group }} @@ -51,7 +72,7 @@ jobs: name: prebuilds-${{ matrix.build-group }} path: prebuilds/ release: - needs: build + needs: [build-linux, build-macos-windows] name: Release to npm runs-on: ubuntu-latest timeout-minutes: 5 @@ -61,10 +82,8 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 22.5.1 registry-url: https://registry.npmjs.org - - name: Update npm - run: npm install -g npm@10 - name: Install run: npm ci --ignore-scripts - name: Download artifacts From e7895d68f09935dd0d763e0a879f4378c6394a68 Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Mon, 22 Jul 2024 07:38:58 -0700 Subject: [PATCH 2/5] delete test workflow --- .../release-no-prebuildify-cross.yml | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 .github/workflows/release-no-prebuildify-cross.yml diff --git a/.github/workflows/release-no-prebuildify-cross.yml b/.github/workflows/release-no-prebuildify-cross.yml deleted file mode 100644 index 4f871e1..0000000 --- a/.github/workflows/release-no-prebuildify-cross.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: new-build - -on: workflow_dispatch - # push: - # tags: ['*'] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - HUSKY: 0 - -permissions: - contents: read - -jobs: - build-linux: - # strategy: - # matrix: - # image: - # - linux-arm64 - # - centos7 - # - alpine - name: Build linux versions - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up node - uses: actions/setup-node@v4 - with: - node-version: 22.5.1 - - name: Install dependencies - run: npm ci --ignore-scripts - # build each image inline so the matrix doesn't checkout, install, install each time. - - name: Build alpine - run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/bmacnaughton/alpine - - name: Build centos7 - run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/bmacnaughton/centos7 - - name: Build linux-arm64 - run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/bmacnaughton/linux-arm64 - # now upload what was built - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: prebuilds-linux - path: prebuilds/ - build-macos-windows: - strategy: - matrix: - include: - - os: macos-latest - build-group: darwin - - os: windows-latest - build-group: win32 - name: Build ${{ matrix.build-group }} - runs-on: ${{ matrix.os }} - timeout-minutes: 10 - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up node - uses: actions/setup-node@v4 - with: - node-version: 22.5.1 - - name: Install dependencies - run: npm ci --ignore-scripts - - name: Build - run: npm run build:${{ matrix.build-group }} - shell: bash - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: prebuilds-${{ matrix.build-group }} - path: prebuilds/ - # release: - # needs: [build-linux, build-macos-windows] - # name: Release to npm - # runs-on: ubuntu-latest - # timeout-minutes: 5 - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - # - name: Set up node - # uses: actions/setup-node@v4 - # with: - # node-version: 22.5.1 - # registry-url: https://registry.npmjs.org - # - name: Install - # run: npm ci --ignore-scripts - # - name: Download artifacts - # uses: actions/download-artifact@v4 - # with: - # pattern: prebuilds-* - # path: prebuilds/ - # merge-multiple: true - # - name: Publish to npm - # run: npm publish - # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 1a556b7485ef66cec5fc90ac05a908a5858d1fd0 Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Mon, 22 Jul 2024 10:32:58 -0700 Subject: [PATCH 3/5] PR feedback/decisions --- .github/workflows/release.yml | 13 +++++-------- .github/workflows/test.yml | 2 +- README.md | 17 ++++++++++++----- package.json | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1483e2b..8b23935 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,6 @@ -name: new-build +name: release -on: - workflow_dispatch: - push: - tags: ['v[0-9]+.[0-9]+.[0-9]+'] +on: workflow_dispatch concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -26,7 +23,7 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: 22.5.1 + node-version: 22 - name: Install dependencies run: npm ci --ignore-scripts # build each image inline so the matrix doesn't checkout, install, install each time. @@ -60,7 +57,7 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: 22.5.1 + node-version: 22 - name: Install dependencies run: npm ci --ignore-scripts - name: Build @@ -82,7 +79,7 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: 22.5.1 + node-version: 22 registry-url: https://registry.npmjs.org - name: Install run: npm ci --ignore-scripts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0651c13..0902804 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - node: [16, 18, 20, 22.5.1] + node: [16, 18, 20, 22] os: [ubuntu-latest, macos-latest, windows-latest] name: Node v${{ matrix.node }} (${{ matrix.os }}) runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index b83f2a2..bc3647f 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,17 @@ const results = funcInfo(testFn); ## Publishing -Simply run `npm version` and `git push && git push --tags`. The `release` workflow runs when -a tag of the form `v1.2.3` is pushed. +Simply run `npm version` and then invoke the `release` workflow. You can run +`release` using the github UI or, if you have the github CLI installed, you +can run `gh workflow run release.yml` (also available via `npm run release`). -## Temporary code +Note that `upload-artifacts@v4` no longer works when there are multiple +artifacts with the same name. That's why the `release` workflow has the +following section: -Node version 22.5.0 ships with a very broken `npm`. This hardcodes version 22.5.1 until -github actions stops defaulting to 22.5.0 when node version 22 is specified. +``` + uses: actions/upload-artifact@v4 + with: + name: prebuilds-${{ matrix.build-group }} + path: prebuilds/ +``` diff --git a/package.json b/package.json index 362d69b..991b8f0 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,11 @@ "prepare": "husky install", "prebuild": "npm run clean", "build": "prebuildify -t 16.9.1 -t 18.7.0 -t 20.5.0 -t 22.2.0 --strip --napi false", - "build:linux": "prebuildify-cross -i centos7-devtoolset7 -i alpine -i linux-arm64 -t 16.9.1 -t 18.7.0 -t 20.5.0 -t 22.2.0 --strip --napi false", "build:darwin": "npm run build -- --arch x64+arm64", "build:win32": "npm run build", "clean": "rimraf build/ coverage/ prebuilds/", "download": "node scripts/download-artifacts.js", + "release": "gh workflow run release.yaml", "test": "c8 --reporter lcov --reporter text mocha .", "test:valgrind": "valgrind --xml=yes --xml-file=./valgrind.xml --trace-children=yes --leak-check=full --show-leak-kinds=all mocha . && node scripts/parse-valgrind.js" }, From ea9823f1c33379371a9085b882e16f7ae70fba83 Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Mon, 22 Jul 2024 10:35:25 -0700 Subject: [PATCH 4/5] remove -w --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b23935..9656840 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,11 +28,11 @@ jobs: run: npm ci --ignore-scripts # build each image inline so the matrix doesn't checkout, install, install each time. - name: Build alpine - run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/contrast-security-oss/alpine + run: docker run --rm -v ${{ github.workspace }}:/repo -u $(id -u) ghcr.io/contrast-security-oss/alpine - name: Build centos7 - run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/contrast-security-oss/centos7 + run: docker run --rm -v ${{ github.workspace }}:/repo -u $(id -u) ghcr.io/contrast-security-oss/centos7 - name: Build linux-arm64 - run: docker run --rm -v ${{ github.workspace }}:/repo -w /repo -u $(id -u) ghcr.io/contrast-security-oss/linux-arm64 + run: docker run --rm -v ${{ github.workspace }}:/repo -u $(id -u) ghcr.io/contrast-security-oss/linux-arm64 # now upload what was built - name: Upload artifact uses: actions/upload-artifact@v4 From 3778a33358f731c08a7387262f1d79139159ebf0 Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Mon, 22 Jul 2024 11:17:03 -0700 Subject: [PATCH 5/5] capitalize Release --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9656840..73f6470 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: release +name: Release on: workflow_dispatch