Repository navigation
124 lines (102 loc) · 3.54 KB
/
Copy pathrelease-provenance.yml
File metadata and controls
124 lines (102 loc) · 3.54 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
# Release workflow with npm provenance.
# Author: Admilson B. F. Cossa
# SPDX-License-Identifier: Apache-2.0
name: Release Provenance
on:
workflow_dispatch:
inputs:
dry_run:
description: Run npm publish as a dry run.
required: true
default: "true"
type: choice
options:
- "true"
- "false"
permissions:
contents: read
attestations: write
id-token: write
jobs:
node-compatibility:
name: Node ${{ matrix.node-version }} compatibility
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ["20.11.1", "22.x", "24.x"]
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Verify Node compatibility
run: npm run check:node-compatibility
publish:
name: Verify and publish
runs-on: ubuntu-latest
needs: node-compatibility
env:
TRUSTED_PUBLISHING_NPM_VERSION: "12.1.0"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version: "22.x"
registry-url: https://registry.npmjs.org
- name: Install trusted-publishing npm client
shell: bash
run: npm install --global "npm@$TRUSTED_PUBLISHING_NPM_VERSION"
- name: Verify trusted-publishing environment
shell: bash
run: |
test "$(npm --version)" = "$TRUSTED_PUBLISHING_NPM_VERSION"
test -n "$ACTIONS_ID_TOKEN_REQUEST_URL"
test -n "$ACTIONS_ID_TOKEN_REQUEST_TOKEN"
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: "1.3.13"
- name: Setup Deno
uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282
with:
deno-version: "2.2.7"
- name: Install dependencies
run: npm ci
- name: Configure signed tag verification
run: git config --global gpg.ssh.allowedSignersFile "$GITHUB_WORKSPACE/.github/allowed_signers"
- name: Verify package
run: npm run verify
- name: Verify coverage
run: npm run test:coverage
- name: Verify release evidence readiness
run: npm run check:release-readiness
- name: Verify release tag
if: inputs.dry_run == 'false'
shell: bash
run: |
test "$GITHUB_REF_TYPE" = "tag"
package_version="$(node -p "require('./packages/core/package.json').version")"
test "$GITHUB_REF_NAME" = "v$package_version"
git tag -v "$GITHUB_REF_NAME"
- name: Prepare ephemeral dry-run version
if: inputs.dry_run == 'true'
shell: bash
run: |
dry_run_version="0.0.0-dry-run.${GITHUB_RUN_ID}.${GITHUB_RUN_ATTEMPT}"
npm pkg set "version=$dry_run_version" --workspace @workit/core
- name: Publish dry run
if: inputs.dry_run == 'true'
run: npm publish --workspace @workit/core --provenance --access public --tag dry-run --dry-run
- name: Publish
if: inputs.dry_run == 'false'
run: npm publish --workspace @workit/core --provenance --access public