Repository navigation
174 lines (156 loc) · 6.43 KB
/
Copy pathrelease.yml
File metadata and controls
174 lines (156 loc) · 6.43 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
name: Release
# Cuts a versioned release of the examples and templates on main:
#
# 1. Checks that the version is X.Y.Z, that vX.Y.Z doesn't exist yet, and
# finds the previous vX.Y.Z tag for the notes range.
# 2. Packs the commit with `git archive` into a source tarball, generates an
# SPDX SBOM from the tarball's package-lock.json files, and writes
# SHA256SUMS for both and the repository's OpenVEX document. Every asset
# is named after the release, as wasmcloud-typescript-vX.Y.Z.*.
# 3. Attests SLSA build provenance for the tarball, the SBOM and SHA256SUMS,
# and attests the SBOM against the tarball. Both are Sigstore-signed and
# verifiable with `gh attestation verify --repo wasmCloud/typescript`.
# 4. Creates the vX.Y.Z tag and GitHub Release at the commit, with generated
# notes under a Changelog heading and the tarball, SBOM, SHA256SUMS and
# Sigstore bundles attached.
#
# release-tag.yml in wasmCloud/wasmCloud starts it with a wasmcloud-release
# repository_dispatch after each stable wasmCloud release, so this release takes
# wasmCloud's version. workflow_dispatch is for a manual or recovery release.
#
# Templates are used straight from the tag with
# `wash new ... --subfolder templates/<name> --git-ref vX.Y.Z`; the tarball is
# the signed copy of the same tree.
#
# The v1 releases (washboard-ui@*, @wasmcloud/*@*) were cut from the v1 branch
# and use different tag names, so they never enter the notes range.
on:
repository_dispatch:
types: [wasmcloud-release]
workflow_dispatch:
inputs:
version:
description: 'Version to release, as X.Y.Z (tagged vX.Y.Z)'
required: true
type: string
permissions: {}
concurrency:
group: release
cancel-in-progress: false
env:
SYFT_VERSION: v1.55.0
VERSION: ${{ github.event.client_payload.version || inputs.version }}
jobs:
release:
name: Tag and release
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.repository == 'wasmCloud/typescript' && github.ref == 'refs/heads/main'
permissions:
# Creating the tag and the GitHub Release.
contents: write
# Sigstore signing and the attestation store.
id-token: write
attestations: write
# actions/attest writes an artifact storage record alongside the
# attestation; without this it warns on every subject.
artifact-metadata: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .tool-versions
package-manager-cache: false
- name: Check version
id: ver
run: node scripts/release-check-version.mjs
- name: Pack source tarball
env:
NAME: ${{ steps.ver.outputs.name }}
SHA: ${{ steps.ver.outputs.sha }}
run: |
set -euo pipefail
mkdir dist
# gzip -n leaves out the timestamp, so the tarball is reproducible
# from the commit.
git archive --format=tar --prefix="$NAME/" "$SHA" | gzip -n -9 > "dist/$NAME.tar.gz"
mkdir "$RUNNER_TEMP/src"
tar -xzf "dist/$NAME.tar.gz" -C "$RUNNER_TEMP/src"
- name: Install Syft
uses: anchore/sbom-action/download-syft@66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c # v0.24.3
with:
syft-version: ${{ env.SYFT_VERSION }}
- name: Generate SBOM
env:
NAME: ${{ steps.ver.outputs.name }}
run: |
set -euo pipefail
syft scan "dir:$RUNNER_TEMP/src/$NAME" \
--source-name wasmcloud-typescript \
--source-version "$VERSION" \
--output "spdx-json=dist/$NAME.spdx.json"
- name: Stage VEX
env:
NAME: ${{ steps.ver.outputs.name }}
# The repository's OpenVEX document: the advisories that don't affect
# this project, as of this release.
run: cp vex.openvex.json "dist/$NAME.openvex.json"
- name: Write checksums
working-directory: dist
env:
NAME: ${{ steps.ver.outputs.name }}
run: sha256sum "$NAME.tar.gz" "$NAME.spdx.json" "$NAME.openvex.json" > "$NAME.SHA256SUMS"
- name: Attest build provenance
id: provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: |
dist/${{ steps.ver.outputs.name }}.tar.gz
dist/${{ steps.ver.outputs.name }}.spdx.json
dist/${{ steps.ver.outputs.name }}.openvex.json
dist/${{ steps.ver.outputs.name }}.SHA256SUMS
- name: Attest SBOM
id: sbom
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: dist/${{ steps.ver.outputs.name }}.tar.gz
sbom-path: dist/${{ steps.ver.outputs.name }}.spdx.json
- name: Stage Sigstore bundles
env:
NAME: ${{ steps.ver.outputs.name }}
PROVENANCE_BUNDLE: ${{ steps.provenance.outputs.bundle-path }}
SBOM_BUNDLE: ${{ steps.sbom.outputs.bundle-path }}
run: |
set -euo pipefail
cp "$PROVENANCE_BUNDLE" "dist/$NAME.provenance.sigstore.json"
cp "$SBOM_BUNDLE" "dist/$NAME.sbom.sigstore.json"
- name: Write release notes
env:
TAG: ${{ steps.ver.outputs.tag }}
PREVIOUS_TAG: ${{ steps.ver.outputs.previous_tag }}
NAME: ${{ steps.ver.outputs.name }}
run: node scripts/release-notes.mjs
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.ver.outputs.tag }}
PREVIOUS_TAG: ${{ steps.ver.outputs.previous_tag }}
SHA: ${{ steps.ver.outputs.sha }}
# --generate-notes appends the changelog since the previous release,
# pinned to it: left to itself GitHub would start from the latest
# release, which may be a v1-branch package release.
run: |
set -euo pipefail
changelog=()
[ -n "$PREVIOUS_TAG" ] && changelog=(--generate-notes --notes-start-tag "$PREVIOUS_TAG")
gh release create "$TAG" dist/* \
--target "$SHA" \
--title "$TAG" \
--notes-file "$RUNNER_TEMP/notes.md" \
--latest \
"${changelog[@]}"