-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (51 loc) · 1.96 KB
/
release-samples-lib.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
name: Release Sample Schemas Library
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
publish-npm:
runs-on: ubuntu-latest
env:
working-directory: ./npm-samples-lib
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- run: npm install -g yarn
- name: install packages
run: yarn
working-directory: ${{env.working-directory}}
- 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
working-directory: ${{env.working-directory}}
- 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 "develop-${{ steps.job_context.outputs.version }}-rc" | sed 's/[.]//g')
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}