-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (55 loc) · 1.75 KB
/
release-next.yml
File metadata and controls
66 lines (55 loc) · 1.75 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
name: Release @consentry/next
on:
push:
branches:
- main
paths:
- 'consentry-next/**'
permissions:
contents: write
jobs:
release:
name: Build and Publish @consentry/next
runs-on: ubuntu-latest
defaults:
run:
working-directory: consentry-next
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Determine version and tag
id: versioning
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="next-v$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag already exists."
echo "should_publish=false" >> $GITHUB_OUTPUT
else
echo "Tag does not exist."
echo "should_publish=true" >> $GITHUB_OUTPUT
fi
- name: Build package
if: steps.versioning.outputs.should_publish == 'true'
run: npm run build
- name: Publish to npm
if: steps.versioning.outputs.should_publish == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Git tag
if: steps.versioning.outputs.should_publish == 'true'
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag ${{ steps.versioning.outputs.tag }}
git push origin ${{ steps.versioning.outputs.tag }}