-
Notifications
You must be signed in to change notification settings - Fork 658
Expand file tree
/
Copy pathrelease.wac.ts
More file actions
152 lines (149 loc) · 5.93 KB
/
release.wac.ts
File metadata and controls
152 lines (149 loc) · 5.93 KB
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
import { createWorkflow } from "github-actions-wac";
import { BUILD_PACKAGES_RUNNER } from "./utils";
import { createJob } from "./jobs";
import {
createGlobalBuildCacheSteps,
createInstallBuildSteps,
createRunBuildCacheSteps,
createYarnCacheSteps,
withCommonParams
} from "./steps";
const BRANCH_NAME = "${{ github.event.inputs.branch }}";
const DIST_TAG = "${{ github.event.inputs.tag }}";
const installBuildSteps = createInstallBuildSteps({ workingDirectory: BRANCH_NAME });
const yarnCacheSteps = createYarnCacheSteps({ workingDirectory: BRANCH_NAME });
const globalBuildCacheSteps = createGlobalBuildCacheSteps({ workingDirectory: BRANCH_NAME });
const runBuildCacheSteps = createRunBuildCacheSteps({ workingDirectory: BRANCH_NAME });
export const release = createWorkflow({
name: `📦 Release`,
on: {
workflow_dispatch: {
inputs: {
branch: {
description: "Branch to release from",
required: true,
default: "next",
type: "choice",
options: ["next", "dev", "v5-dev"]
},
tag: {
description: `NPM tag (in most cases, "beta" is what you need)`,
required: false,
default: "beta"
}
}
}
},
jobs: {
constants: createJob({
name: "Create constants",
outputs: {
"global-cache-key": "${{ steps.global-cache-key.outputs.global-cache-key }}",
"run-cache-key": "${{ steps.run-cache-key.outputs.run-cache-key }}"
},
steps: [
{
name: "Create global cache key",
id: "global-cache-key",
run: `echo "global-cache-key=${BRANCH_NAME}-\${{ runner.os }}-$(/bin/date -u "+%m%d")-\${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT`
},
{
name: "Create workflow run cache key",
id: "run-cache-key",
run: 'echo "run-cache-key=${{ github.run_id }}-${{ github.run_attempt }}-${{ vars.RANDOM_CACHE_KEY_SUFFIX }}" >> $GITHUB_OUTPUT'
}
]
}),
build: createJob({
name: "Build",
needs: "constants",
checkout: { path: BRANCH_NAME, ref: BRANCH_NAME },
"runs-on": BUILD_PACKAGES_RUNNER,
steps: [
...yarnCacheSteps,
...globalBuildCacheSteps,
...installBuildSteps,
...runBuildCacheSteps
]
}),
npmReleaseBeta: createJob({
needs: ["constants", "build"],
name: `NPM release ("${DIST_TAG}" tag)`,
env: {
GH_TOKEN: "${{ secrets.GH_TOKEN }}",
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}",
BETA_VERSION: "${{ vars.BETA_VERSION }}"
},
checkout: { path: BRANCH_NAME, ref: BRANCH_NAME, "fetch-depth": 0 },
steps: [
...yarnCacheSteps,
...runBuildCacheSteps,
...installBuildSteps,
...withCommonParams(
[
{
name: 'Create ".npmrc" file in the project root',
run: 'echo "//registry.npmjs.org/:_authToken=\\${NPM_TOKEN}" > .npmrc'
},
{
name: "Set git email",
run: 'git config --global user.email "webiny-bot@webiny.com"'
},
{
name: "Set git username",
run: 'git config --global user.name "webiny-bot"'
},
{
name: 'Version and publish "beta" tag to NPM',
"working-directory": BRANCH_NAME,
run: `yarn release --type=beta --tag=${DIST_TAG}`
}
],
{ "working-directory": BRANCH_NAME }
)
]
}),
npmReleaseLatest: createJob({
needs: ["constants", "npmReleaseBeta"],
name: 'NPM release ("latest" tag)',
environment: "release",
env: {
GH_TOKEN: "${{ secrets.GH_TOKEN }}",
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}",
LATEST_VERSION: "${{ vars.LATEST_VERSION }}"
},
checkout: {
path: BRANCH_NAME,
ref: BRANCH_NAME,
"fetch-depth": 0
},
steps: [
...yarnCacheSteps,
...runBuildCacheSteps,
...installBuildSteps,
...withCommonParams(
[
{
name: 'Create ".npmrc" file in the project root',
run: 'echo "//registry.npmjs.org/:_authToken=\\${NPM_TOKEN}" > .npmrc'
},
{
name: "Set git email",
run: 'git config --global user.email "webiny-bot@webiny.com"'
},
{
name: "Set git username",
run: 'git config --global user.name "webiny-bot"'
},
{
name: 'Version and publish "latest" tag to NPM',
"working-directory": BRANCH_NAME,
run: `yarn release --type=latest --sourceTag=${DIST_TAG} --createGithubRelease=true`
}
],
{ "working-directory": BRANCH_NAME }
)
]
})
}
});