forked from codler/react-ga4
-
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (43 loc) · 1.26 KB
/
publish.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
name: Publish
on:
push:
branches: main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
- name: Get package version
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
- name: Check previous tags
uses: mukunku/tag-exists-action@v1.4.0
id: checkTag
with:
tag: v${{ env.PACKAGE_VERSION }}
- name: Build
if: steps.checkTag.outputs.exists == 'false'
run: yarn build && yarn postbuild
- name: Tag new version
if: steps.checkTag.outputs.exists == 'false'
uses: anothrNick/github-tag-action@1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: v${{ env.PACKAGE_VERSION }}
- name: Publish
if: steps.checkTag.outputs.exists == 'false'
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}