-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (167 loc) · 6.23 KB
/
publish.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Publish
on:
workflow_dispatch:
inputs:
version:
required: true
description: 'Version (e.g. "1.0.0-rc1")'
jobs:
publish:
timeout-minutes: 15
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3.6.0
with:
node-version: 16.x
- name: Install dependencies
run: npm install --prefer-offline --no-fund --no-progress
- name: Initialize deployment
id: deployment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = /^[0-9]+\.[0-9]+\.[0-9]+$/.test("${{ github.event.inputs.version }}") ? 'latest' : 'preview';
const deployment = await github.rest.repos.createDeployment({
environment: tag,
ref: '${{ github.sha }}',
owner: context.repo.owner,
repo: context.repo.repo
});
core.setOutput('id', deployment.data.id);
core.setOutput('tag', tag);
- name: Parameters
run: |
echo SHA ${{ github.sha }}
echo Branch ${{ github.ref }}
echo Version ${{ github.event.inputs.version }}
echo NPM Tag ${{ steps.deployment.outputs.tag }}
echo Deployment ${{ steps.deployment.outputs.id }}
- name: Build & Test
run: |
npm run build:eslint -- --version ${{ github.event.inputs.version }}
npm run build:prettier -- --version ${{ github.event.inputs.version }}
npm run test
- name: Create Release
id: release
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: 'v${{ github.event.inputs.version }}',
target_commitish: context.sha,
name: '${{ github.event.inputs.version }}',
body: '',
draft: false,
prerelease: '${{ steps.deployment.outputs.tag }}' !== 'latest'
});
core.setOutput('upload_url', release.data.upload_url);
- name: Pack "legacy"
working-directory: packages/legacy
run: npm pack
- name: Pack "commonjs"
working-directory: packages/commonjs
run: npm pack
- name: Pack "esmodules"
working-directory: packages/esmodules
run: npm pack
- name: Pack "typescript"
working-directory: packages/typescript
run: npm pack
- name: Pack "prettier"
working-directory: packages/prettier
run: npm pack
- name: Attach "legacy"
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./packages/legacy/wildpeaks-eslint-config-legacy-${{ github.event.inputs.version }}.tgz
asset_name: legacy.tgz
asset_content_type: application/gzip
- name: Attach "commonjs"
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./packages/commonjs/wildpeaks-eslint-config-commonjs-${{ github.event.inputs.version }}.tgz
asset_name: commonjs.tgz
asset_content_type: application/gzip
- name: Attach "esmodules"
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./packages/esmodules/wildpeaks-eslint-config-esmodules-${{ github.event.inputs.version }}.tgz
asset_name: esmodules.tgz
asset_content_type: application/gzip
- name: Attach "typescript"
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./packages/typescript/wildpeaks-eslint-config-typescript-${{ github.event.inputs.version }}.tgz
asset_name: typescript.tgz
asset_content_type: application/gzip
- name: Attach "prettier"
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./packages/prettier/wildpeaks-prettier-config-${{ github.event.inputs.version }}.tgz
asset_name: prettier.tgz
asset_content_type: application/gzip
- name: Set token
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_DEPLOY_KEY }}
- name: Publish "legacy"
run: npm publish --tag ${{ steps.deployment.outputs.tag }}
working-directory: packages/legacy
- name: Publish "commonjs"
run: npm publish --tag ${{ steps.deployment.outputs.tag }}
working-directory: packages/commonjs
- name: Publish "esmodules"
run: npm publish --tag ${{ steps.deployment.outputs.tag }}
working-directory: packages/esmodules
- name: Publish "typescript"
run: npm publish --tag ${{ steps.deployment.outputs.tag }}
working-directory: packages/typescript
- name: Publish "prettier"
run: npm publish --tag ${{ steps.deployment.outputs.tag }}
working-directory: packages/prettier
- name: On success
if: success()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: '${{ steps.deployment.outputs.id }}',
state: 'success'
});
- name: On error
if: failure() || cancelled()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: '${{ steps.deployment.outputs.id }}',
state: 'failure'
});