generated from designsystemet/design-tokens
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 1.44 KB
/
npm-publish-on-version-change.yml
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
name: Tag and publish on version change
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '21.x'
registry-url: 'https://npm.pkg.github.com'
- name: Fetch all tags
run: git fetch --tags
- name: Check if version has changed
run: |
VERSION=$(npm pkg get version --workspaces=false | tr -d '"')
if git tag -l "v$VERSION" | grep -q "v$VERSION"; then
echo "Tag v$VERSION already exists."
echo "tag_exists=true" >> $GITHUB_ENV
else
echo "Tag v$VERSION does not exist."
echo "tag_exists=false" >> $GITHUB_ENV
echo "current_version=$VERSION" >> $GITHUB_ENV
fi
- name: Tag the commit
if: env.tag_exists == 'false'
run: |
VERSION=${{ env.current_version }}
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git tag -a "v$VERSION" -m "Release version $VERSION"
git push origin "v$VERSION"
# - name: Publish to GPR
# if: env.tag_exists == 'false'
# run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO setup publishing to npmjs