Repository navigation
74 lines (63 loc) · 2.62 KB
/
Copy pathrelease.yml
File metadata and controls
74 lines (63 loc) · 2.62 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
name: Release
# Actions are pinned to full commit hashes, which cannot be moved, with their release in a
# comment. Dependabot proposes updates (.github/dependabot.yml).
# Pushing a version tag on main (v1.2.3, or v1.2.3-rc.1 for a pre-release) publishes a GitHub
# release with the SDK package attached. Version tags can be created but never moved or deleted.
on:
push:
tags: ["v*"]
permissions:
contents: write # create the release and attach the package
id-token: write # sign the build provenance attestation
attestations: write # store the attestation
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Full history, to check that the tagged commit is on main.
fetch-depth: 0
- name: Check the tag
run: |
version="${GITHUB_REF_NAME#v}"
package_version="$(node -p "require('./sdk/package.json').version")"
if [ "$version" != "$package_version" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match the SDK version $package_version."
exit 1
fi
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::Tag $GITHUB_REF_NAME is not on main."
exit 1
fi
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
package_json_file: sdk/package.json
cache: true
cache_dependency_path: sdk/pnpm-lock.yaml
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
- name: Test and build the SDK
working-directory: sdk
run: |
pnpm install --frozen-lockfile
pnpm test
pnpm build
- name: Pack the SDK
working-directory: sdk
run: pnpm pack --pack-destination "$GITHUB_WORKSPACE"
# A signed statement that this workflow built the package from the tagged commit. Anyone can
# check it: gh attestation verify <file> --repo Morphora-Lab/morcast-protocol
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: morcast-protocol-*.tgz
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
run: |
prerelease=""
case "$GITHUB_REF_NAME" in *-*) prerelease="--prerelease" ;; esac
gh release create "$GITHUB_REF_NAME" morcast-protocol-*.tgz \
--verify-tag --generate-notes --title "$GITHUB_REF_NAME" $prerelease