-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (52 loc) · 1.9 KB
/
publish.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
name: Publish
on:
push:
branches:
- main
- patch*
pull_request:
branches:
- main
- patch*
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 18
- name: Install
run: yarn
- name: Build
run: yarn build
- name: Test
run: yarn test --detectOpenHandles --forceExit
- name: Setup Custom Contexts
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
echo "##[set-output name=version;]$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')"
echo "##[set-output name=short_sha;]$(git rev-parse --short HEAD)"
id: job_context
- name: Make snapshot version
if: steps.job_context.outputs.branch != 'main'
run: |
npm version prerelease --preid=${{ steps.job_context.outputs.short_sha }} --git-tag-version false
working-directory: ${{env.working-directory}}
- name: Publish package to latest
if: steps.job_context.outputs.branch == 'main'
working-directory: ${{env.working-directory}}
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish package to branch-tag
if: steps.job_context.outputs.branch != 'main'
working-directory: ${{env.working-directory}}
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts --access public --tag $(echo "${{ steps.job_context.outputs.branch }}-${{ steps.job_context.outputs.version }}-rc" | sed 's/[.]//g')
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}