-
Notifications
You must be signed in to change notification settings - Fork 13
271 lines (236 loc) · 8.55 KB
/
deploy.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Deploy
# === Triggers ===
'on':
workflow_run:
workflows: ['Test']
types:
- completed
branches:
- master
- beta
- release
- LTS*
pull_request:
types:
- labeled
- opened
- synchronize
- reopened
# === Workflow Permissions ===
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
# === Workflow-level environment variables ===
env:
AWS_REGION: us-east-1
AWS_ROLE_SESSION_NAME: gha-activestate-cli
# === JOBS ===
jobs:
# === OS Specific Job (runs on each OS) ===
os_specific:
name: ${{ matrix.sys.os }}
timeout-minutes: 90
strategy:
matrix:
go-version:
- 1.20.x
sys:
- { os: ubuntu-20.04 }
- { os: macos-11, shell: zsh }
- { os: windows-2019 }
fail-fast: false
runs-on: ${{ matrix.sys.os }}
env:
ACTIVESTATE_CI: true
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
SHELL: bash
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency:
group: ${{ github.ref }}-${{ github.event_name }}-${{ matrix.sys.os }}
cancel-in-progress: true
# === OS Specific Steps ===
steps:
- # === Disable Windows Defender as it slows things down significantly ===
name: Disabling Windows Defender
if: runner.os == 'Windows'
shell: powershell
run: Set-MpPreference -DisableRealtimeMonitoring $true
- # === Checkout Code ===
name: Checkout code
uses: actions/checkout@v2
- # === Install Go ===
name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1
- # === Setup ===
name: Setup
shell: bash
run: |
bin=$(pwd)/.github/deps/${{ runner.os }}/bin
echo "Adding $bin to PATH"
echo "$bin" >> $GITHUB_PATH
if [ -x "$(command -v apt-get)" ]; then
sudo apt-get update
sudo apt-get install fish zsh tcsh -y
# Prevent zsh insecure directory warning.
sudo chmod -R 755 /usr/share/zsh/vendor-completions /usr/share/zsh
sudo chown -R root:root /usr/share/zsh/vendor-completions /usr/share/zsh
touch ~/.zshrc
fi
printenv
- # === Setup Windows ===
name: Setup (Windows)
shell: pwsh
run: |
echo "${PSScriptRoot}/.github/deps/${{ runner.os }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- # == Setup macOS ==
name: Setup (macOS)
shell: bash
run: brew install fish
if: runner.os == 'macOS'
- # === Install Deps ===
name: Install Deps
shell: bash
run: state run install-deps
- # === Preprocess ===
name: Preprocess
shell: bash
timeout-minutes: 3
run: state run preprocess -v
- # === Prepare Windows Cert ===
name: Prepare Windows Cert
shell: bash
if: runner.os == 'Windows'
run: |
echo $MSI_CERT_BASE64 | base64 --decode > Cert.p12
env:
MSI_CERT_BASE64: ${{ secrets.MSI_CERT_BASE64 }}
- # === Sign Binaries (Windows only) ===
name: Sign Binaries (Windows only)
shell: bash
if: runner.os == 'Windows' && contains(fromJSON('["refs/heads/beta", "refs/heads/release", "refs/heads/LTS"]'), github.ref)
run: |
export PATH=/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/:/c/Program\ Files\ \(x86\)/Windows\ Kits/10/bin/10.0.16299.0/x86/:$PATH
signtool.exe sign -d "ActiveState State Tool" -f "Cert.p12" -p ${CODE_SIGNING_PASSWD} ./build/state.exe
signtool.exe sign -d "ActiveState State Service" -f "Cert.p12" -p ${CODE_SIGNING_PASSWD} ./build/state-svc.exe
signtool.exe sign -d "ActiveState State Installer" -f "Cert.p12" -p ${CODE_SIGNING_PASSWD} ./build/state-installer.exe
signtool.exe sign -d "ActiveState State Tool Remote Installer" -f "Cert.p12" -p ${CODE_SIGNING_PASSWD} ./build/state-remote-installer.exe
env:
CODE_SIGNING_PASSWD: ${{ secrets.CODE_SIGNING_PASSWD }}
- # === Sign Install Scripts (Windows only) ===
name: Sign Install Scripts (Windows only)
shell: powershell
if: runner.os == 'Windows' && contains(fromJSON('["refs/heads/beta", "refs/heads/release", "refs/heads/LTS"]'), github.ref)
run: |
$branchInfix = $Env:GITHUB_REF.Replace("refs/heads/", "").Replace("release", "")
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import('Cert.p12',$env:CODE_SIGNING_PASSWD,'DefaultKeySet')
Set-AuthenticodeSignature -FilePath build\installers\$branchInfix\install.ps1 -Certificate $cert
Set-AuthenticodeSignature -FilePath build\installers\$branchInfix\legacy-install.ps1 -Certificate $cert
env:
CODE_SIGNING_PASSWD: ${{ secrets.CODE_SIGNING_PASSWD }}
- # === Configure AWS credentials ==
name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ env.AWS_REGION }}
mask-aws-account-id: true
# === Deploy job (runs once with combined artifacts from OS specific job) ===
deploy:
name: Deploy
needs:
- os_specific
runs-on: ubuntu-20.04
env:
ACTIVESTATE_CI: true
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
SHELL: bash
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 10
if: contains(fromJSON('["refs/heads/master", "refs/heads/beta", "refs/heads/release", "refs/heads/LTS"]'), github.ref) || startsWith(github.event.pull_request.head.ref, 'version/')
# === Deploy Steps ===
steps:
- # === Checkout code ===
name: Checkout code
uses: actions/checkout@v2
- # === Install Go ===
name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1
- # === Setup ===
name: Setup
shell: bash
run: |
bin=$(pwd)/.github/deps/${{ runner.os }}/bin
echo "Adding $bin to PATH"
echo "$bin" >> $GITHUB_PATH
ls -ahl $bin
printenv
- # === Download All Build Session Artifacts ===
name: Download All Build Session Artifacts
uses: actions/download-artifact@v2
with:
path: build/
- # === Sanitize All Session Artifacts ===
name: Sanitize All Session Artifacts
shell: bash
run: |
cd build
rm -Rf session-shared-build
find . -mindepth 2 -maxdepth 2 -print0 | xargs -0 -I file rsync -av file .
rm -Rf session*
- # === Install Deps ===
name: Install Deps
shell: bash
run: state run install-deps
- # === Preprocess ===
name: Preprocess
shell: bash
run: state run preprocess -v
- # === Cleanup Build Dir ===
name: Cleanup Build Dir
shell: bash
run: rm build/state* || true
- # === Configure AWS credentials ==
name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ env.AWS_REGION }}
mask-aws-account-id: true
- # === Generate updated master versions.json if necessary ===
name: Generate version list
shell: bash
run: state run generate-versions-list
- # === Deploy ===
name: Deploy
shell: bash
run: |
state run deploy-updates
state run deploy-installers
state run deploy-remote-installer
- # === Cleanup Session Artifacts ===
name: Cleanup Session Artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: |
session-build-ubuntu-20.04
session-build-macos-11
session-build-windows-2019
- # === Upload Artifacts ===
name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: build/