-
Notifications
You must be signed in to change notification settings - Fork 26
87 lines (76 loc) · 2.53 KB
/
reusable_release-npm.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: "Release to NPM"
on:
workflow_call:
inputs:
create-dev-release:
required: false
type: boolean
default: false
create-rc-release:
required: false
type: boolean
default: false
secrets:
CAP_GH_RELEASE_TOKEN:
required: true
NPM_TOKEN:
required: true
permissions:
contents: write
id-token: write
jobs:
build:
runs-on: 'ubuntu-22.04'
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CAP_GH_RELEASE_TOKEN }}
- name: 'Setup Tools'
uses: ./.github/actions/setup-tools
- name: 'Check Current Release Type'
shell: bash
run: |
RELEASE_TYPE="$([[ "$(git describe --abbrev=0 --tags)" =~ ^[0-9]{1,}[\.][0-9]{1,}[\.][0-9]{1,}[-]((beta)|(rc)|(alpha))[\.][0-9]{1,}$ ]] && echo "prerelease" || echo "release")"
echo "releasetype=$RELEASE_TYPE" >> $GITHUB_ENV
- name: "NPM Identity"
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
npm whoami
- name: "Git Config"
run: |
git config user.name "Github Workflow (on behalf of ${{ github.actor }})"
git config user.email "users.noreply.github.com"
- name: 'Dev Release'
if: inputs.create-dev-release
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.CAP_GH_RELEASE_TOKEN }}
run: |
pnpm ci:publish:dev
- name: 'RC Release'
if: "!inputs.create-dev-release && inputs.create-rc-release"
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.CAP_GH_RELEASE_TOKEN }}
run: |
pnpm run ci:publish:rc
- name: 'Release from PreRelease'
if: ${{ !inputs.create-dev-release && !inputs.create-rc-release && env.releasetype == 'prerelease' }}
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.CAP_GH_RELEASE_TOKEN }}
run: |
pnpm run ci:publish:latest-from-pre
- name: 'Release from Release'
if: ${{ !inputs.create-dev-release && !inputs.create-rc-release && env.releasetype == 'release' }}
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.CAP_GH_RELEASE_TOKEN }}
run: |
pnpm run ci:publish:latest