-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (64 loc) · 1.82 KB
/
deploy.yaml
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
name: publish
on:
push:
branches: [master]
paths: ['package.json']
jobs:
diff:
runs-on: ubuntu-22.04
outputs:
previous: ${{ steps.version.outputs.previous }}
current: ${{ steps.version.outputs.current }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: version
run: |
previous=$(git show HEAD^:package.json | grep '"version"' | awk -F '"' '{print $4}')
current=$(git show HEAD:package.json | grep '"version"' | awk -F '"' '{print $4}')
echo "previous=v$previous" >> $GITHUB_OUTPUT
echo "current=v$current" >> $GITHUB_OUTPUT
create-tag:
needs: diff
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.tag.outputs.tag }}
if: needs.diff.outputs.previous != needs.diff.outputs.current
steps:
- uses: actions/checkout@v4
- id: tag
run: |
tag=${{ needs.diff.outputs.current }}
git tag $tag
git push origin $tag
echo "tag=$tag" >> $GITHUB_OUTPUT
create-release:
needs: create-tag
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-tag.outputs.tag }}
release_name: ${{ needs.create-tag.outputs.tag }}
draft: false
prerelease: false
npm-publish:
needs: create-release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com
scope: '@choewy'
- env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm ci
npm run build
npm publish