-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (60 loc) · 1.83 KB
/
Copy pathrelease-on-merge.yml
File metadata and controls
70 lines (60 loc) · 1.83 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
name: Release on Merge
on:
push:
branches: [main]
paths:
# Triggers on version bump; actual release check happens in check-release job
- 'package.json'
jobs:
check-release:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check if release needed
id: check
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping release"
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "Tag $TAG does not exist, will create release"
echo "should_release=true" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
release-and-publish:
needs: check-release
if: needs.check-release.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ needs.check-release.outputs.version }}"
gh release create "v$VERSION" \
--title "v$VERSION" \
--generate-notes
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: yarn install
- name: Build
run: yarn dev:build
- name: Prepack
run: npm run prepack
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}