-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (46 loc) · 1.57 KB
/
deploy.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
52
53
54
55
56
57
name: Publish to npm
on:
push:
branches:
- main
jobs:
release:
name: Publish
runs-on: ubuntu-latest
environment: rep
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: npm install
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
- name: Configure git identity
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Get version from package.json
id: get_version
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
- name: Check if tag exists
run: |
if git rev-parse v${{ steps.get_version.outputs.version }} >/dev/null 2>&1; then
echo "Tag v${{ steps.get_version.outputs.version }} already exists"
fi
- name: Remove existing tag if exists
run: |
if git rev-parse v${{ steps.get_version.outputs.version }} >/dev/null 2>&1; then
git push --delete origin v${{ steps.get_version.outputs.version }}
git tag -d v${{ steps.get_version.outputs.version }}
fi
- name: Create tag
run: |
git tag -a v${{ steps.get_version.outputs.version }} -m "Version ${{ steps.get_version.outputs.version }}"
git push origin v${{ steps.get_version.outputs.version }}