forked from ArmaanT/cdkactions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
169 lines (161 loc) · 3.88 KB
/
main.ts
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
import { Construct } from "constructs";
import { App, Stack, Workflow, Job, CheckoutJob } from "cdkactions";
export class JSIIReleaseStack extends Stack {
constructor(scope: Construct, name: string) {
super(scope, name);
// Build workflow
const build = new Workflow(this, "build", {
name: 'Build',
on: ["pullRequest", "push"]
});
new CheckoutJob(build, 'build', {
runsOn: 'ubuntu-latest',
container: {
image: 'jsii/superchain'
},
steps: [
{
name: 'Install dependencies',
run: 'yarn install --frozen-lockfile'
},
{
name: 'Set version',
run: 'tools/align-version.sh'
},
{
name: 'Compile',
run: 'yarn build'
},
{
name: 'Unit Tests',
run: 'yarn test'
},
{
name: 'Code Coverage',
run: 'yarn codecov'
},
{
name: 'Create Bundle',
run: 'yarn package'
},
{
name: 'Integration Tests',
// run: 'yarn integration'
run: 'echo TODO: add these'
}
]
});
// Release workflow
const release = new Workflow(this, "release", {
name: 'Release',
on: { push: { branches: ['master'] } }
});
new CheckoutJob(release, 'build_artifact', {
name: 'Build and upload artifact',
if: "github.repository == 'ArmaanT/cdkactions'",
runsOn: 'ubuntu-latest',
container: {
image: 'jsii/superchain'
},
steps: [
{
name: 'Install dependencies',
run: 'yarn install --frozen-lockfile'
},
{
name: 'Set version',
run: 'tools/align-version.sh'
},
{
name: 'Compile',
run: 'yarn build'
},
{
name: 'Unit Tests',
run: 'yarn test'
},
{
name: 'Code Coverage',
run: 'yarn codecov'
},
{
name: 'Create Bundle',
run: 'yarn package'
},
{
name: 'Integration Tests',
// run: 'yarn integration'
run: 'echo TODO: add these'
},
{
name: 'Upload artifact',
uses: 'actions/upload-artifact@v1',
with: {
name: 'dist',
path: 'dist'
}
},
{
name: 'Release to GitHub',
run: 'tools/release-github.sh',
env: {
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}',
REPO: '${{ github.repository }}',
}
},
]
});
new Job(release, 'release_npm', {
name: 'Release to NPM',
needs: 'build_artifact',
runsOn: 'ubuntu-latest',
container: {
image: 'jsii/superchain'
},
steps: [
{
name: 'Download build artifacts',
uses: 'actions/download-artifact@v1',
with: {
name: 'dist'
}
},
{
name: 'Release',
run: 'npx -p jsii-release jsii-release-npm',
env: {
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}'
}
}
]
});
new Job(release, 'release_pypi', {
name: 'Release to PyPI',
needs: 'build_artifact',
runsOn: 'ubuntu-latest',
container: {
image: 'jsii/superchain'
},
steps: [
{
name: 'Download build artifacts',
uses: 'actions/download-artifact@v1',
with: {
name: 'dist'
}
},
{
name: 'Release',
run: 'npx -p jsii-release jsii-release-pypi',
env: {
TWINE_USERNAME: '${{ secrets.TWINE_USERNAME }}',
TWINE_PASSWORD: '${{ secrets.TWINE_PASSWORD }}'
}
}
]
});
}
}
const app = new App();
new JSIIReleaseStack(app, 'jsii');
app.synth();