Skip to content

Commit 78a9564

Browse files
committed
ci: enable pipeline publishing
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent f935f15 commit 78a9564

File tree

6 files changed

+1213
-547
lines changed

6 files changed

+1213
-547
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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

.github/workflows/cd.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
permissions: {}
8+
9+
jobs:
10+
test:
11+
name: Test
12+
uses: ./.github/workflows/ci.yaml
13+
build:
14+
name: Build
15+
needs: test
16+
permissions:
17+
id-token: write
18+
contents: read
19+
actions: read
20+
# Do not pin to hash
21+
# See: https://github.com/slsa-framework/slsa-verifier/issues/12
22+
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
23+
with:
24+
node-version: 22
25+
run-scripts: ci, test
26+
publish:
27+
name: Publish
28+
runs-on: ubuntu-24.04
29+
needs: [build]
30+
permissions:
31+
contents: read
32+
id-token: write
33+
steps:
34+
- name: Harden Runner
35+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
36+
with:
37+
egress-policy: audit
38+
- name: Download Tarball
39+
uses: slsa-framework/slsa-github-generator/actions/nodejs/[email protected]
40+
with:
41+
name: ${{ needs.build.outputs.package-download-name }}
42+
path: ${{ needs.build.outputs.package-name }}
43+
sha256: ${{ needs.build.outputs.package-download-sha256 }}
44+
- name: Download Provenance
45+
uses: slsa-framework/slsa-github-generator/actions/nodejs/[email protected]
46+
with:
47+
name: ${{ needs.build.outputs.provenance-download-name }}
48+
path: attestations
49+
sha256: ${{ needs.build.outputs.provenance-download-sha256 }}
50+
- name: Publish Dry-Run
51+
env:
52+
TARBALL_PATH: ${{ needs.build.outputs.package-name }}
53+
run: npm publish --dry-run "$TARBALL_PATH"
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"

.github/workflows/ci.yaml

Lines changed: 69 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: CI
22

33
on:
44
push:
5-
branches: [ v9 ]
5+
branches: [v9]
66
pull_request:
7-
branches: [ v9 ]
7+
branches: [v9]
8+
workflow_call:
89

910
jobs:
1011
test:
@@ -15,9 +16,9 @@ jobs:
1516
fail-fast: false
1617
matrix:
1718
os:
18-
- ubuntu-latest
19+
- ubuntu-24.04
1920
- macos-13
20-
- windows-latest
21+
- windows-2022
2122
node-version:
2223
- 8
2324
- 9
@@ -34,38 +35,76 @@ jobs:
3435
- 20
3536
- 21
3637
- 22
38+
- 23
3739
steps:
38-
- uses: actions/checkout@v2
39-
- name: Use Node.js ${{ matrix.node-version }}
40-
uses: actions/setup-node@v1
41-
with:
42-
node-version: ${{ matrix.node-version }}
43-
- name: Install Dependencies
44-
if: matrix.node-version != 9
45-
run: npm ci --ignore-scripts
46-
- name: Install Dependencies (Node.js v9)
47-
if: matrix.node-version == 9
48-
run: npm install
49-
- name: Run Tests
50-
if: matrix.os != 'windows-latest'
51-
run: npm test
52-
- name: Run Tests (Windows)
53-
if: matrix.os == 'windows-latest'
54-
run: npm run-script test-windows
55-
- name: Publish Coverage
56-
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 16 # LTS
57-
uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057
58-
with:
59-
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Harden Runner
41+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
42+
with:
43+
disable-sudo: true
44+
egress-policy: block
45+
allowed-endpoints: >
46+
api.github.com:443
47+
coveralls.io:443
48+
github.com:443
49+
nodejs.org:443
50+
objects.githubusercontent.com:443
51+
registry.npmjs.org:443
52+
- name: Checkout Repository
53+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
- name: Use Node.js ${{ matrix.node-version }}
55+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
56+
with:
57+
node-version: ${{ matrix.node-version }}
58+
- name: Install Dependencies
59+
if: matrix.node-version != 9
60+
run: npm ci --ignore-scripts
61+
- name: Install Dependencies (Node.js v9)
62+
if: matrix.node-version == 9
63+
run: npm install
64+
- name: Run Tests
65+
if: ${{ ! startsWith(matrix.os, 'windows-') }}
66+
run: npm test
67+
- name: Run Tests (Windows)
68+
if: startsWith(matrix.os, 'windows-')
69+
shell: cmd
70+
run: npm run test-windows
71+
- name: Publish Coverage
72+
if: github.event != 'workflow_dispatch'
73+
uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 # v2.3.4
74+
with:
75+
flag-name: run-${{ matrix.os }}-node@${{ matrix.node-version }}
76+
github-token: ${{ secrets.GITHUB_TOKEN }}
77+
parallel: true
78+
post-test:
79+
name: Post-Test
80+
needs: test
81+
if: ${{ (github.event != 'workflow_dispatch') && success() }}
82+
runs-on: ubuntu-24.04
83+
steps:
84+
- name: Coveralls Finished
85+
uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 # v2.3.4
86+
with:
87+
github-token: ${{ secrets.GITHUB_TOKEN }}
88+
parallel-finished: true
6089
code-lint:
6190
name: Code Lint
62-
runs-on: ubuntu-latest
91+
runs-on: ubuntu-24.04
6392
steps:
64-
- uses: actions/checkout@v2
93+
- name: Harden Runner
94+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
95+
with:
96+
disable-sudo: true
97+
egress-policy: block
98+
allowed-endpoints: >
99+
api.github.com:443
100+
github.com:443
101+
objects.githubusercontent.com:443
102+
registry.npmjs.org:443
103+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
65104
- name: Use Node.js 16
66-
uses: actions/setup-node@v1
105+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
67106
with:
68-
node-version: 16 # LTS
107+
node-version: 22 # LTS
69108
- name: Install Dependencies
70109
run: npm ci --ignore-scripts
71110
- name: Lockfile Lint

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
/nbproject
44
npm-debug.log
55
node-ipc.cjs
6-
/spec/coverage/
6+
/coverage/
7+
8+
# Code editors
9+
\#*#
10+
.#*
11+
*~

0 commit comments

Comments
 (0)