-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 1.73 KB
/
release.yml
File metadata and controls
63 lines (53 loc) · 1.73 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
name: Release and Publish
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- name: Use Node LTS ✨
uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: https://registry.npmjs.org
cache: pnpm
- name: Install dependencies 📦️
run: pnpm install --frozen-lockfile
- name: Build package
run: pnpm build
- name: Check if version changed
id: version-check
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Check if tag already exists
if git tag -l | grep -q "^v$CURRENT_VERSION$"; then
echo "version_changed=false" >> $GITHUB_OUTPUT
else
echo "version_changed=true" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
if: steps.version-check.outputs.version_changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version-check.outputs.current_version }}
release_name: Release v${{ steps.version-check.outputs.current_version }}
draft: false
prerelease: false
- name: Publish to npm
if: steps.version-check.outputs.version_changed == 'true'
run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}