Repository navigation
80 lines (80 loc) · 3.2 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (80 loc) · 3.2 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
name: Release
on:
workflow_dispatch:
inputs:
publish:
description: Publish the verified candidate (requires completed maintainer checklist)
type: boolean
default: false
tag:
description: Existing signed release tag; required only for publication
type: string
default: ''
permissions:
contents: read
concurrency:
group: geoptimize-release
cancel-in-progress: false
jobs:
request:
runs-on: ubuntu-latest
steps:
- name: Reject an unauthorized publication request
if: inputs.publish
env:
ENABLED: ${{ vars.RELEASE_ENABLED }}
REF: ${{ github.ref }}
TAG: ${{ inputs.tag }}
run: |
test "$ENABLED" = true
test "$REF" = refs/heads/main
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
validate:
needs: request
uses: ./.github/workflows/ci.yml
publish:
needs: validate
if: inputs.publish && github.ref == 'refs/heads/main' && vars.RELEASE_ENABLED == 'true'
runs-on: ubuntu-latest
environment: npm-release
permissions:
contents: write
id-token: write
attestations: write
env:
RELEASE_TAG: ${{ inputs.tag }}
GH_TOKEN: ${{ github.token }}
steps:
- 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: 24
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-assets
path: ${{ runner.temp }}/release-assets
- name: Verify source, signed tag, candidate and unpublished version
run: bash scripts/verify-release-publication.sh "$RUNNER_TEMP/release-assets"
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: ${{ runner.temp }}/release-assets/geoptimize-*.tgz
- name: Stage all assets in a draft release
run: |
gh release create "$RELEASE_TAG" --verify-tag --draft --title "geoptimize ${RELEASE_TAG#v}" --notes-file docs/release-notes-v0.12.md
gh release upload "$RELEASE_TAG" "$RUNNER_TEMP/release-assets/"*.tgz "$RUNNER_TEMP/release-assets/SHA256SUMS" "$RUNNER_TEMP/release-assets/"*.spdx.json
- name: Publish the verified tarball using npm OIDC
run: |
# Recheck main immediately before the irreversible operation.
test "$(gh api repos/cucuwang/geoptimize/git/ref/heads/main --jq .object.sha)" = "$GITHUB_SHA"
(cd "$RUNNER_TEMP/release-assets" && sha256sum --check SHA256SUMS)
npm publish "$RUNNER_TEMP/release-assets/geoptimize-${RELEASE_TAG#v}.tgz" --access public --provenance --ignore-scripts
- name: Finalize the fully populated release
run: gh release edit "$RELEASE_TAG" --draft=false --latest
- name: Verify public npm, GitHub and tag alignment
run: |
sha=$(jq -r .sha256 "$RUNNER_TEMP/release-assets/candidate.json")
bash scripts/verify-release-public.sh "$GITHUB_SHA" "$sha"