Repository navigation
184 lines (161 loc) · 7.92 KB
/
Copy pathpublish.yml
File metadata and controls
184 lines (161 loc) · 7.92 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Publish @bitgo-beta
on:
workflow_dispatch:
# push:
# branches:
# - master
permissions:
contents: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
SOCKET_SECURITY_MODE: monitor # Options: monitor (non-blocking) or block (fails on vulnerabilities)
jobs:
publish:
name: Publish Release
runs-on: ubuntu-latest
# Normal runs finish well inside this. The worst case stacks the lerna-step
# prepack timeout (20 min), the global propagation wait (15 min), recovery
# bumps, and the fallback publish's own sibling wait (20 min) — this cap
# covers that with headroom while still failing out of a registry outage
# instead of holding the runner for hours.
# Empirical floors (WCI-1858/WCI-2113): healthy-day green 43 min (Nov 3),
# storm-recovery green 78 min (Oct 29) — 22 min under this cap. A cap-kill
# costs a full re-release (prepare-release recomputes +1 for every package
# each run, so there is no bitgo-only redo). Do not trim this number.
timeout-minutes: 100
# Restricts @bitgo-beta/@bitgo-alpha publishing to protected branches via
# a deployment branch policy on this environment, so the job cannot run
# from arbitrary PR branches even though it is manually dispatched.
environment: beta-alpha-release
steps:
- uses: socketdev/action@4337a545deecc20f19a909e52db7a2f6ba292f42 # v1
with:
mode: firewall-free
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
- name: Install BitGoJS
run: sfw yarn install --with-frozen-lockfile
# osv-scanner has no severity filter and exits non-zero on ANY finding,
# so run it with continue-on-error and let the severity gate below
# decide pass/fail based on CVSS score (fails on HIGH/CRITICAL only).
- name: Audit Dependencies
id: osv-scan
continue-on-error: true
uses: google/osv-scanner-action/osv-scanner-action@9a498708959aeaef5ef730655706c5a1df1edbc2 # v2.3.8
with:
scan-args: |-
--config=osv-scanner.toml
--format=json
--output-file=osv-results.json
./
- name: Enforce Vulnerability Severity Threshold
uses: ./.github/actions/osv-severity-gate
with:
scan-outcome: ${{ steps.osv-scan.outcome }}
- name: Set Environment Variable for Alpha
if: github.ref != 'refs/heads/master' # only publish changes if on feature branches
run: |
echo "preid=alpha" >> $GITHUB_ENV
- name: Set Environment Variable for Beta
if: github.ref == 'refs/heads/master' # only publish changes if on master branches
run: |
echo "preid=beta" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.name 'Git bot'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git checkout -b ${{ env.preid }}-$(git rev-parse --short HEAD)
- name: Configure NPM for Trusted Publishing
run: |
echo "@bitgo-beta:registry=https://registry.npmjs.org" >> .npmrc
- name: Prepare Release
run: |
rm -rfd ./modules/web-demo
rm -rfd ./modules/express
npx tsx ./scripts/prepare-release.ts ${{ env.preid }}
- name: Rebuild packages
run: sfw yarn
- name: Commit Local Changes
run: git commit -am "Auto updated ${{ env.preid }} branch" --no-verify || echo "No changes to commit"
- name: Lerna Publish (siblings)
id: lerna-siblings
# The lerna exit code is not a reliable failure signal: a Rekor TLOG 409 is
# usually a duplicate submission of provenance whose registry write already
# completed, and npm can report failure for versions it then publishes fine.
# Verify Publish is the registry-truth gate: it polls the exact-version
# endpoint and only republishes (bumping the version on staged conflicts)
# for packages that genuinely never landed. Set RECOVERY_MODE=false in that
# script's env to restore fail-fast behavior.
# The tee'd log records what lerna actually published so Verify Publish can
# skip its propagation wait for versions that never existed. GitHub's
# default run shell (bash -e) has NO pipefail — shell: bash opts into
# -eo pipefail so lerna's exit code survives the pipe and the step
# outcome stays failure under continue-on-error.
continue-on-error: true
shell: bash
run: >-
yarn lerna publish from-package --preid ${{ env.preid }} --dist-tag ${{ env.preid }}
--force-publish --yes --loglevel silly 2>&1 | tee /tmp/lerna-siblings-publish.log
env:
NPM_CONFIG_PROVENANCE: true
- name: Warn on failed siblings publish
# outcome is the real result; conclusion is masked to success by
# continue-on-error, which is why the step badge cannot be trusted.
if: steps.lerna-siblings.outcome == 'failure'
run: >-
echo "::warning::Lerna siblings publish failed (continue-on-error). Verify Publish
will republish whatever is missing. See the Lerna Publish (siblings) step log for
the per-package errors."
- name: Lerna Publish (bitgo)
id: lerna-bitgo
# Non-fatal for the same reason as the siblings step; a bitgo failure here
# (e.g. its prepack sibling-visibility wait timing out) is retried by
# Verify Publish with BITGO_GENERATE_SHRINKWRAP enabled.
# This step usually fails with EUNCOMMIT on storm days: an aborted siblings
# wave leaves its rewritten package.jsons uncommitted, and lerna refuses a
# dirty tree. That instant skip is DESIRABLE — fixing it would run a 20-min
# prepack against dependencies that are not on npm yet. Verify Publish's
# fallback publishes bitgo after the settle has republished its deps. On
# healthy days this step publishes bitgo itself, shrinkwrap included.
continue-on-error: true
# shell: bash for -eo pipefail — see the siblings step: without it the
# tee'd pipeline masks lerna's failure (the green-badge trap).
shell: bash
run: |
bitgo_name=$(jq -r '.name' modules/bitgo/package.json)
yarn lerna publish from-package --include-private "$bitgo_name" --preid ${{ env.preid }} --dist-tag ${{ env.preid }} --force-publish --yes --loglevel silly 2>&1 | tee /tmp/lerna-bitgo-publish.log
env:
NPM_CONFIG_PROVENANCE: true
BITGO_GENERATE_SHRINKWRAP: true
- name: Warn on failed bitgo publish
if: steps.lerna-bitgo.outcome == 'failure'
run: >-
echo "::warning::Lerna bitgo publish failed (continue-on-error). Verify Publish
will publish bitgo via its fallback path after the settle pass."
- name: Verify Publish
run: npx tsx ./scripts/verify-release.ts ${{ env.preid }}
env:
NPM_CONFIG_PROVENANCE: true
RECOVERY_MODE: true
LERNA_SIBLINGS_PUBLISH_LOG: /tmp/lerna-siblings-publish.log
LERNA_BITGO_PUBLISH_LOG: /tmp/lerna-bitgo-publish.log
- name: Upload lerna publish logs on failure
# The tee'd logs are the ground truth for what lerna actually published
# (Verify parses them); the step log is the only other copy and is
# painful to grep at --loglevel silly volumes. Runs after Verify so it
# also captures the case where only Verify Publish failed.
if: failure()
uses: actions/upload-artifact@v7
with:
name: lerna-publish-logs
path: |
/tmp/lerna-siblings-publish.log
/tmp/lerna-bitgo-publish.log
retention-days: 7