-
Notifications
You must be signed in to change notification settings - Fork 11
51 lines (49 loc) · 1.72 KB
/
release.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
name: Release
on:
push:
branches:
- 'master'
jobs:
build:
runs-on: ubuntu-latest
environment: npm
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org
- name: Install
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
- id: tagExistsAndVersion
name: Check if tags exist in NPM and GIT
run: |
set +e
packageName="$(node -p "require('./package').name")"
packageVersion="$(node -p "require('./package').version")"
packageNameAndVersion="${packageName}@${packageVersion}"
npm view "${packageNameAndVersion}" dist.tarball | grep "${packageVersion}" > /dev/null
npmTagExists="$([ "$?" = "0" ] && BOOL="true" || BOOL="false"; echo $BOOL)"
set -e
echo "::set-output name=npmTagExists::${npmTagExists}"
echo "::set-output name=packageVersion::${packageVersion}"
- name: Publish
if: ${{ steps.tagExistsAndVersion.outputs.npmTagExists == 'false'}}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.LIFEOMIC_NPM_TOKEN}}
- name: Create Release
if: ${{ steps.tagExistsAndVersion.outputs.npmTagExists == 'false'}}
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.tagExistsAndVersion.outputs.packageVersion }}
release_name: v${{ steps.tagExistsAndVersion.outputs.packageVersion }}
draft: false
prerelease: false