-
Notifications
You must be signed in to change notification settings - Fork 3
102 lines (86 loc) · 3.33 KB
/
release.yml
File metadata and controls
102 lines (86 loc) · 3.33 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
name: Release to npm (provenance + signed assets)
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
publish:
if: github.repository == 'recodeee/gitguardex'
runs-on: ubuntu-latest
environment: npm
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
registry-url: https://registry.npmjs.org
cache: npm
- name: Install Cosign
uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1
- name: Install
run: npm ci --ignore-scripts
- name: Verify
run: |
npm test
node --check bin/multiagent-safety.js
npm pack --dry-run
- name: Resolve package metadata
id: pkg
run: |
echo "name=$(node -p "require('./package.json').name")" >> "$GITHUB_OUTPUT"
echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
- name: Check npm registry for current version
id: registry
env:
PACKAGE_NAME: ${{ steps.pkg.outputs.name }}
PACKAGE_VERSION: ${{ steps.pkg.outputs.version }}
run: |
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
echo "already_published=true" >> "$GITHUB_OUTPUT"
else
echo "already_published=false" >> "$GITHUB_OUTPUT"
fi
- name: Pack release tarball
id: pack
run: |
mkdir -p dist
package_file="$(npm pack --pack-destination dist | tail -n 1)"
echo "package_file=${package_file}" >> "$GITHUB_OUTPUT"
echo "package_path=dist/${package_file}" >> "$GITHUB_OUTPUT"
- name: Publish with provenance
if: ${{ steps.registry.outputs.already_published != 'true' }}
run: npm publish --provenance --access public
- name: Skip already-published npm version
if: ${{ steps.registry.outputs.already_published == 'true' }}
env:
PACKAGE_NAME: ${{ steps.pkg.outputs.name }}
PACKAGE_VERSION: ${{ steps.pkg.outputs.version }}
run: echo "${PACKAGE_NAME}@${PACKAGE_VERSION} is already on npm; skipping publish."
- name: Generate release checksum
run: |
sha256sum "${{ steps.pack.outputs.package_path }}" > "${{ steps.pack.outputs.package_path }}.sha256"
- name: Sign release tarball with Sigstore
run: |
cosign sign-blob "${{ steps.pack.outputs.package_path }}" \
--bundle "${{ steps.pack.outputs.package_path }}.sigstore.json" \
--yes
- name: Upload signed release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event.release.tag_name || format('v{0}', steps.pkg.outputs.version) }}
run: |
gh release upload "$RELEASE_TAG" \
"${{ steps.pack.outputs.package_path }}" \
"${{ steps.pack.outputs.package_path }}.sha256" \
"${{ steps.pack.outputs.package_path }}.sigstore.json" \
--clobber