Repository navigation
164 lines (141 loc) · 5.32 KB
/
Copy pathrelease.yml
File metadata and controls
164 lines (141 loc) · 5.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Release & Dual-Publish CI
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions: read-all
jobs:
test-matrix:
name: Test Matrix (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
node-version: [20, 22, 24]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
run_install: false
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Test Suite
run: pnpm test
build-and-attest:
name: Build, SLSA Provenance & SBOM
needs: [test-matrix]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
run_install: false
- name: Setup Node.js 22
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.0.0
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Package
run: pnpm run build
- name: Pack Release Tarballs
run: |
mkdir -p release-artifacts
npm pack --pack-destination release-artifacts
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
fs.writeFileSync('package.alias.json', JSON.stringify({ ...pkg, name: 'devshelf' }, null, 2));
"
cp package.json package.orig.json
mv package.alias.json package.json
npm pack --pack-destination release-artifacts
mv package.orig.json package.json
- name: Generate SLSA Build Provenance Attestation
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: 'release-artifacts/*.tgz'
- name: Generate CycloneDX SBOM
uses: anchore/sbom-action@dfcb83b97731532d72be422cbc51ee64adb6fd56 # v0.24.4
with:
path: ./
format: 'cyclonedx-json'
output-file: 'release-artifacts/devshelf-cyclonedx.sbom.json'
artifact-name: 'devshelf-cyclonedx.sbom.json'
upload-artifact: true
upload-release-assets: false
- name: Generate SPDX SBOM
uses: anchore/sbom-action@dfcb83b97731532d72be422cbc51ee64adb6fd56 # v0.24.4
with:
path: ./
format: 'spdx-json'
output-file: 'release-artifacts/devshelf-spdx.sbom.json'
artifact-name: 'devshelf-spdx.sbom.json'
upload-artifact: true
upload-release-assets: false
- name: Upload Build Artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.0
with:
name: dist-artifacts
path: release-artifacts/
retention-days: 30
dual-publish:
name: Dual-Publish to npm & GitHub Packages
needs: [build-and-attest]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js 22
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Download Build Artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.0
with:
name: dist-artifacts
path: release-artifacts/
- name: Publish scoped and unscoped tarballs to npm with Provenance
run: |
npm publish release-artifacts/ritualdev-lab-devshelf-*.tgz --access public --provenance
npm publish release-artifacts/devshelf-[0-9]*.tgz --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish scoped package to GitHub Packages
run: |
echo "@ritualdev-lab:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> .npmrc
npm publish release-artifacts/ritualdev-lab-devshelf-*.tgz --provenance=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Attach Release & SBOM Assets to GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@c062e08bd5328157348241fa0833b7d8b97943b7 # v2.0.8
with:
generate_release_notes: true
files: |
release-artifacts/*.tgz
release-artifacts/*.sbom.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}