-
Notifications
You must be signed in to change notification settings - Fork 93
61 lines (53 loc) · 2.01 KB
/
release.yml
File metadata and controls
61 lines (53 loc) · 2.01 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
# Unified workflow for both prerelease and stable releases
# Prerelease: triggered on push to main
# Stable: triggered on push of tag matching 'v*.*.*'
# NOTE: The reason this is all done in one workflow is because npmjs.com only
# allows one GH Actions file to be setup as a trusted publisher.
name: Publish npm package
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: current
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: npm ci
- name: Determine version and tag
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# Stable release: use tag version
VERSION=${GITHUB_REF#refs/tags/v}
npm version "$VERSION" --no-git-tag-version
TAG="latest"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Setting version to $VERSION for stable release"
else
# Prerelease: bump from latest stable tag
LATEST_TAG=$(git tag --list "v*.*.*" --sort=-v:refname | grep -v '-' | head -n1)
npm version "${LATEST_TAG#v}" --no-git-tag-version
npm version prerelease --preid="dev.${{ github.sha }}" --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
TAG="dev"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Setting version to $VERSION for prerelease"
fi
- name: Build with remote save enabled
run: VITE_REMOTE_SERVER_URL= VITE_ENABLE_REMOTE_SAVE=true npm run build
- name: Publish to npm
run: npm publish --tag ${{ steps.version.outputs.tag }} --access public --provenance