generated from CatChen/typescript-github-action-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (136 loc) · 3.86 KB
/
release.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Release
on:
schedule:
- cron: '0 12 * * 0'
workflow_dispatch:
inputs:
release-type:
description: 'Release Type'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
prerelease:
description: 'Prerelease'
required: true
default: false
type: boolean
skip-if-no-diff:
description: 'Skip if no diff'
required: true
default: false
type: boolean
diff-targets:
description: 'Diff Targets'
required: false
default: '{README.md,LICENSE,bundle}'
type: string
dry-run:
description: 'Dry run'
required: true
default: false
type: boolean
jobs:
build:
uses: ./.github/workflows/build.yml
permissions:
pull-requests: write
contents: write
secrets: inherit
test:
uses: ./.github/workflows/test.yml
secrets: inherit
eslint:
uses: ./.github/workflows/eslint.yml
codeql:
uses: ./.github/workflows/codeql.yml
permissions:
security-events: write
packages: read
actions: read
contents: read
release:
name: Release
needs: [build, test, eslint, codeql]
concurrency: release
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release.outputs.tag }}
skipped: ${{ steps.release.outputs.skipped }}
steps:
- uses: actions/create-github-app-token@v1
id: get-github-app-token
with:
app-id: ${{ secrets.ACCEPT_TO_SHIP_BOT_APP_ID }}
private-key: ${{ secrets.ACCEPT_TO_SHIP_BOT_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
ref: 'main'
fetch-depth: 0
token: ${{ steps.get-github-app-token.outputs.token }}
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: true
registry-url: https://registry.npmjs.org/
cache: yarn
- id: release
uses: CatChen/node-package-release-action@v2
with:
release-type: ${{ inputs.release-type || 'patch' }}
prerelease: ${{ inputs.prerelease || false }}
update-shorthand-release: true
dry-run: ${{ inputs.dry-run || false }}
skip-if-no-diff: ${{ inputs.skip-if-no-diff || github.event_name != 'workflow_dispatch' }}
diff-targets: ${{ inputs.diff-targets || '{README.md,LICENSE,bundle}' }}
github-token: ${{ steps.get-github-app-token.outputs.token }}
publish:
name: Publish
needs: [release]
if: ${{ needs.release.outputs.skipped != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: ${{ !inputs.dry-run }}
with:
ref: ${{ needs.release.outputs.tag }}
- uses: actions/checkout@v4
if: ${{ inputs.dry-run }}
with:
ref: ${{ github.ref_name || github.ref }}
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: true
registry-url: https://registry.npmjs.org/
cache: yarn
- name: Build
run: |
yarn install
yarn build
- name: Publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
DRY_RUN: ${{ inputs.dry-run || false }}
run: |
NPM_WHOAMI=$(npm whoami)
echo "::notice::NPM username: $NPM_WHOAMI"
echo "::group::npm config"
npm config ls -l
echo "::endgroup::"
echo "::group::npm publish"
if [[ "$DRY_RUN" = true ]]
then
npm publish --dry-run
else
npm publish
fi
echo "::endgroup::"