-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (79 loc) · 2.81 KB
/
release.yml
File metadata and controls
90 lines (79 loc) · 2.81 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write # to create GitHub Releases
id-token: write # for npm publish provenance
jobs:
release:
name: Build + GitHub Release + npm publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Verify package.json version matches tag
id: ver
run: |
TAG="${GITHUB_REF#refs/tags/v}"
PKG=$(node -p "require('./package.json').version")
echo "Tag version: $TAG"
echo "package.json version: $PKG"
if [ "$TAG" != "$PKG" ]; then
echo "::error::Tag $TAG does not match package.json version $PKG"
exit 1
fi
echo "version=$TAG" >> "$GITHUB_OUTPUT"
- name: Sanity-check (lint + tests)
run: |
pip install -r requirements-dev.txt
ruff check scripts/ tests/
mypy scripts/
pytest -q
- name: Extract release notes from CHANGELOG.md
id: notes
run: |
VERSION="${{ steps.ver.outputs.version }}"
# Extract the section under "## [VERSION]" up to (but not including) the next "## ["
awk -v ver="$VERSION" '
$0 ~ "^## \\[" ver "\\]" { capture=1; next }
capture && /^## \[/ { exit }
capture { print }
' CHANGELOG.md > release-notes.md
{
echo "notes<<__EOF__"
cat release-notes.md
echo "__EOF__"
} >> "$GITHUB_OUTPUT"
- name: Create tarball for the release artefact
run: npm pack --json > pack-output.json
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "webtest-orch v${{ steps.ver.outputs.version }}"
body: ${{ steps.notes.outputs.notes }}
prerelease: ${{ contains(steps.ver.outputs.version, 'beta') || contains(steps.ver.outputs.version, 'alpha') || contains(steps.ver.outputs.version, 'rc') }}
files: |
webtest-orch-*.tgz
release-notes.md
- name: Publish to npm
if: ${{ env.NPM_TOKEN != '' }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [[ "${{ steps.ver.outputs.version }}" == *beta* || "${{ steps.ver.outputs.version }}" == *alpha* || "${{ steps.ver.outputs.version }}" == *rc* ]]; then
npm publish --access public --tag beta --provenance
else
npm publish --access public --provenance
fi