Repository navigation
61 lines (53 loc) · 2.5 KB
/
Copy pathdeploy.yml
File metadata and controls
61 lines (53 loc) · 2.5 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
name: Deploy
# Publishes to npm and creates the GitHub Release when the `release` branch receives a new version.
# `npm run release:archive` on main pushes that snapshot. See CONTRIBUTING.md → Releasing.
on:
push:
branches: [release]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # create the release and tag
id-token: write # npm trusted publishing (OIDC provenance)
issues: write # close the milestone and its issues
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # tags are needed for the version comparison
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
registry-url: https://registry.npmjs.org/
# Without a bump the remaining steps are skipped and the run stays green.
- name: Check that the version was bumped
id: version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
echo "package.json: $PACKAGE_VERSION / last tag: $LAST_TAG"
if [ "$PACKAGE_VERSION" = "$LAST_TAG" ]; then
echo "::notice::Version $PACKAGE_VERSION is already released. Skipping deploy."
echo "bumped=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "bumped=true" >> "$GITHUB_OUTPUT"
echo "version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT"
- if: steps.version.outputs.bumped == 'true'
run: npm ci
- if: steps.version.outputs.bumped == 'true'
run: npm run check
# Trusted publishing needs npm 11.5.1+; the npm bundled with Node 22 is older.
- if: steps.version.outputs.bumped == 'true'
run: npm install -g npm@latest
- name: Publish to npm
if: steps.version.outputs.bumped == 'true'
run: npm publish --provenance --access public
- name: Create GitHub Release and close milestone
if: steps.version.outputs.bumped == 'true'
run: node .github/scripts/manage-deploy.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION_NAME: ${{ steps.version.outputs.version }}