File tree Expand file tree Collapse file tree 6 files changed +153
-14
lines changed
Expand file tree Collapse file tree 6 files changed +153
-14
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: FSFAP
2+ # SPDX-FileCopyrightText: Copyright (c) 2024 Rifa Achrinza
3+ root = true
4+
5+ [* ]
6+ end_of_line = lf
7+ insert_final_newline = true
8+ charset = utf-8
9+ indent_style = space
10+ indent_size = 2
11+ max_line_length = 80
Original file line number Diff line number Diff line change 1+ name : CD
2+
3+ on :
4+ push : {} # Remove me!
5+ workflow_dispatch :
6+ inputs :
7+ branch :
8+ description : Branch to publish a release from
9+ required : true
10+ default : main
11+ type : choice
12+ options :
13+ - main
14+ - v9.x
15+
16+ permissions : {}
17+
18+ jobs :
19+ test :
20+ name : Test
21+ uses : ./.github/workflows/ci.yaml
22+ build :
23+ name : Build
24+ permissions :
25+ id-token : write
26+ contents : read
27+ actions : read
28+ # Do not pin to hash
29+ # See: https://github.com/slsa-framework/slsa-verifier/issues/12
30+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected] 31+ with :
32+ node-version : 22
33+ run-scripts : ci, test
34+ publish :
35+ name : Publish
36+ runs-on : ubuntu-24.04
37+ needs : [build]
38+ permissions :
39+ content : read
40+ id-token : write
41+ steps :
42+ - name : Download Tarball
43+ uses :
slsa-framework/slsa-github-generator/actions/nodejs/[email protected] 44+ with :
45+ name : ${{ needs.build.outputs.package-download-name }}
46+ path : ${{ needs.build.outputs.package-name }}
47+ sha256 : ${{ needs.build.outputs.package-download-sha256 }}
48+ - name : Download Provenance
49+ uses :
slsa-framework/slsa-github-generator/actions/nodejs/[email protected] 50+ with :
51+ name : ${{ needs.build.outputs.provenance-download-name }}
52+ path : attestations
53+ sha256 : ${{ needs.build.outputs.provenance-download-sha256 }}
54+ - name : Request for NPM 2FA Code
55+ uses : step-security/wait-for-secrets@5809f7d044804a5a1d43217fa8f3e855939fc9ef # v1.2.0
56+ with :
57+ secrets : |
58+ npm-otp:
59+ name: NPM Registry OTP
60+ description: NPM Registry TOTP code for `achrinza-bot` NPM account
61+ - name : Publish Package
62+ env :
63+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
64+ TARBALL_PATH : ${{ needs.build.outputs.package-name }}
65+ PROVENANCE_PATH : ./attestations/${{ needs.build.outputs.provenance-name }}
66+ run : |
67+ npm publish \
68+ --access=public \
69+ --provenance-file="$PROVENANCE_PATH" \
70+ "$TARBALL_PATH"
Original file line number Diff line number Diff line change @@ -2,20 +2,23 @@ name: CI
22
33on :
44 push :
5- branches : [ main ]
5+ branches : [main]
66 pull_request :
7- branches : [ main ]
7+ branches : [main]
8+ workflow_call : {}
89
10+ permissions : {}
11+
912jobs :
1013 test :
1114 name : Test
1215 runs-on : ${{ matrix.os }}
1316 strategy :
1417 matrix :
1518 os :
16- - ubuntu-latest
19+ - ubuntu-24.04
1720 - macos-13
18- - windows-latest
21+ - windows-2022
1922 node-version :
2023 - 14
2124 - 16
@@ -25,31 +28,36 @@ jobs:
2528 - 20
2629 - 21
2730 - 22
31+ - 23
2832 steps :
29- - uses : actions/checkout@v2
33+ - name : Checkout Repository
34+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3035 - name : Use Node.js ${{ matrix.node-version }}
31- uses : actions/setup-node@v1
36+ uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
3237 with :
3338 node-version : ${{ matrix.node-version }}
39+ cache : npm
3440 - name : Install Dependencies
35- run : npm ci --ignore-scripts
41+ run : npm ci --prefer-offline -- ignore-scripts
3642 - name : Run Tests
37- run : npm test
43+ run : npm test --ignore-scripts
3844 code-lint :
3945 name : Code Lint
4046 runs-on : ubuntu-latest
4147 steps :
42- - uses : actions/checkout@v2
43- - name : Use Node.js 16
44- uses : actions/setup-node@v1
48+ - name : Checkout Repository
49+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
50+ - name : Use Node.js 22
51+ uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
4552 with :
46- node-version : 16 # LTS
53+ node-version : 22 # LTS
54+ cache : npm
4755 - name : Install Dependencies
48- run : npm ci --ignore-scripts
56+ run : npm ci --prefer-offline -- ignore-scripts
4957 - name : Lockfile Lint
5058 run : |
5159 npm exec \
52- --no-install \
60+ --no \
5361 --package=lockfile-lint \
5462 -- \
5563 lockfile-lint \
Original file line number Diff line number Diff line change 44npm-debug.log
55node-ipc.cjs
66/coverage /
7+
8+ # Code editors
9+ \# * #
10+ . #*
11+ * ~
Original file line number Diff line number Diff line change 1+ # Publishing a Release
2+
3+ This project uses a manually-invoked GitHub Actions workflow to publish its packages.
4+
5+ This workflow uses:
6+ - The SLSA Node.js builder to achieve SLSA v3-level provenance
7+ - An NPM granular access token for ` achrinza-bot `
8+
9+ ## Publishing
10+
11+ Before continuing, enusre that you have:
12+
13+ 1 . A GitHub account with the ` Repository Admin ` role for the ` achrinza/node-ipc ` repository
14+ 2 . The username and password for the ` achrinza-bot ` NPM account or any account that has:
15+ 1 . TOTP 2FA enabled
16+ 2 . Write access to the ` @achrinza/node-ipc ` NPM package
17+ 3 . The TOTP generator for said account
18+
19+ ### 1. Regenerating the NPM Granular Token
20+
21+ 1 . Go to [ New Granular Access Token] ( https://www.npmjs.com/settings/achrinza/tokens/granular-access-tokens/new )
22+ 2 . Generate a granular access token that:
23+ 1 . expires in 1 day
24+ 2 . has ` Read and write ` permssions for only the ` @achrinza/node-ipc ` package.
25+ 3 . Click ` Generate ` and copy the token
26+
27+ ### 2. Creating a GitHub "Release"
28+
29+ 1 . Delete and re-fetch all Git tags
30+ This is necessary to prevent accidental tags from being pushed to the GitHub repository
31+
32+ On Linux or macOS:
33+ ``` sh
34+ $ git branch -l | xargs -I{} git branch -d {}
35+ $ git fetch ' refs/tags/*:refs/tags/*'
36+ ```
37+
38+ On Windows ()
39+
40+ ### 3. Creating an NPM Release
41+
42+ 1 . Go to [ Update Action secret NPM_TOKEN] ( https://github.com/achrinza/node-ipc/settings/secrets/actions/NPM_TOKEN )
43+ 2 . Paste the token and click ` Update secret `
44+ 3 . Go to [ CD * workflow runs] ( https://github.com/achrinza/node-ipc/actions/workflows/cd.yaml )
Original file line number Diff line number Diff line change 3434 "node-http-server" : " ^8.1.4"
3535 },
3636 "scripts" : {
37+ "ci" : " npm ci" ,
3738 "prepare" : " esbuild node-ipc.js --bundle --format=cjs --target=es2018 --platform=node --outfile=node-ipc.cjs" ,
3839 "test" : " c8 -r lcov -r html node test/CI.js && c8 report && node ./lcov.js" ,
3940 "coverage" : " echo 'See your coverage report at http://localhost:8080' && node-http-server port=8080 root=./coverage/"
You can’t perform that action at this time.
0 commit comments