-
Notifications
You must be signed in to change notification settings - Fork 406
197 lines (184 loc) · 7.65 KB
/
Copy pathrelease-cli-stage.yml
File metadata and controls
197 lines (184 loc) · 7.65 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
185
186
187
188
189
190
191
192
193
194
195
196
197
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Stage CLI npm release
on:
workflow_call:
inputs:
version:
description: Exact maka-agent version from packages/cli/package.json
required: true
type: string
permissions:
contents: read
concurrency:
group: cli-npm-stage
cancel-in-progress: false
jobs:
authorize:
name: Resolve product release
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
source_commit: ${{ steps.product.outputs.source_commit }}
product_tag: ${{ steps.product.outputs.product_tag }}
steps:
- name: Check out the trusted publisher
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Require the Apache main publisher
env:
RELEASE_REF: ${{ github.ref }}
RELEASE_REPOSITORY: ${{ github.repository }}
run: |
test "$RELEASE_REPOSITORY" = apache/maka
test "$RELEASE_REF" = refs/heads/main
- name: Check out the approved product source as data
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: v${{ inputs.version }}
path: product-source
fetch-depth: 1
persist-credentials: false
- name: Resolve the exact product release
id: product
env:
GH_TOKEN: ${{ github.token }}
PRODUCT_TAG: v${{ inputs.version }}
run: |
source_commit="$(git -C product-source rev-parse HEAD)"
node scripts/product-release-authority.mjs verify-draft \
"$PRODUCT_TAG" "$source_commit" "$GITHUB_REPOSITORY"
echo "source_commit=$source_commit" >> "$GITHUB_OUTPUT"
echo "product_tag=$PRODUCT_TAG" >> "$GITHUB_OUTPUT"
- name: Verify the product release identity
env:
GITHUB_SHA: ${{ steps.product.outputs.source_commit }}
EXPECTED_PRODUCT_VERSION: ${{ inputs.version }}
PRODUCT_MANIFEST_ROOT: ${{ github.workspace }}/product-source
run: node scripts/product-release-identity.mjs
validate:
name: Validate immutable candidate
needs: authorize
uses: ./.github/workflows/cli-package-validation.yml
with:
source_commit: ${{ needs.authorize.outputs.source_commit }}
stage:
name: Stage maka-agent on npm
needs: [authorize, validate]
runs-on: ubuntu-24.04
timeout-minutes: 15
environment:
name: npm-publication
url: https://www.npmjs.com/package/maka-agent
permissions:
contents: read
id-token: write
steps:
- name: Check out trusted staging code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22.19.0'
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Select the staged-publishing npm toolchain
run: npm install --global --no-audit --no-fund "$(node -p 'require("./package.json").packageManager')"
- name: Download the validated release candidate
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.validate.outputs.release_candidate_artifact_id }}
path: packages/cli/release
- name: Bind the candidate to this workflow run
id: release
env:
EXPECTED_VERSION: ${{ inputs.version }}
PRODUCT_TAG: ${{ needs.authorize.outputs.product_tag }}
RELEASE_REPOSITORY: ${{ github.repository }}
RELEASE_RUN_ID: ${{ github.run_id }}
RELEASE_RUN_ATTEMPT: ${{ github.run_attempt }}
PRODUCT_SOURCE_SHA: ${{ needs.authorize.outputs.source_commit }}
PUBLISHER_SHA: ${{ github.sha }}
RELEASE_WORKFLOW: .github/workflows/npm-publication.yml
run: |
node scripts/release-cli-publication.mjs prepare-stage \
packages/cli/release \
"$EXPECTED_VERSION" \
"$PRODUCT_TAG" \
"$PRODUCT_SOURCE_SHA" \
"$PUBLISHER_SHA" \
"$RELEASE_RUN_ID" \
"$RELEASE_RUN_ATTEMPT" \
"$RELEASE_REPOSITORY" \
"$RELEASE_WORKFLOW" \
"$GITHUB_OUTPUT"
- name: Preserve the exact staged candidate
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cli-staged-release-${{ github.run_attempt }}
path: |
packages/cli/release/*.tgz
packages/cli/release/*.tgz.sha256
packages/cli/release/*.tgz.files.json
packages/cli/release/release.json
if-no-files-found: error
compression-level: 0
retention-days: 30
- name: Record the post-staging approval step
env:
RELEASE_DIST_TAG: ${{ steps.release.outputs.dist_tag }}
RELEASE_VERSION: ${{ steps.release.outputs.version }}
RELEASE_RUN_ID: ${{ github.run_id }}
RELEASE_RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
{
echo "## maka-agent@$RELEASE_VERSION staging"
echo
echo "After this workflow succeeds, review and approve the staged package with 2FA on npmjs.com."
echo "After the package becomes public, run **Finalize product release** with:"
echo
echo "- stage run ID: \`$RELEASE_RUN_ID\`"
echo "- stage run attempt: \`$RELEASE_RUN_ATTEMPT\`"
echo "- version: \`$RELEASE_VERSION\`"
} >> "$GITHUB_STEP_SUMMARY"
- name: Submit the candidate to npm staging
env:
GH_TOKEN: ${{ github.token }}
PREDECESSOR_VERSION: ${{ needs.validate.outputs.release_predecessor_version }}
PREDECESSOR_TARBALL_URL: ${{ needs.validate.outputs.release_predecessor_tarball_url }}
PREDECESSOR_INTEGRITY: ${{ needs.validate.outputs.release_predecessor_integrity }}
PRODUCT_SOURCE_COMMIT: ${{ needs.authorize.outputs.source_commit }}
PRODUCT_TAG: ${{ needs.authorize.outputs.product_tag }}
RELEASE_DIST_TAG: ${{ steps.release.outputs.dist_tag }}
RELEASE_TARBALL: ${{ steps.release.outputs.tarball }}
run: |
node scripts/release-cli-publication.mjs assert-nightly-predecessor \
"$PREDECESSOR_VERSION" \
"$PREDECESSOR_TARBALL_URL" \
"$PREDECESSOR_INTEGRITY"
node scripts/product-release-authority.mjs verify-draft \
"$PRODUCT_TAG" "$PRODUCT_SOURCE_COMMIT" "$GITHUB_REPOSITORY"
npm stage publish "$RELEASE_TARBALL" \
--tag "$RELEASE_DIST_TAG" \
--registry https://registry.npmjs.org/ \
--provenance