-
Notifications
You must be signed in to change notification settings - Fork 14
219 lines (205 loc) · 8.36 KB
/
pkg_msi.yaml
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
name: 'PKG: Microsoft Software Installer (MSI)'
on:
workflow_dispatch:
inputs:
version:
description: 'Package Version'
required: true
default: '0.0.1'
name:
description: 'Package Name'
required: false
default: 'mondoo'
skip-publish:
description: 'Skip publish?'
required: false
default: false
type: boolean
release:
types: [published]
jobs:
setup:
name: 'Setup'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
trimmed-version: ${{ steps.version.outputs.trimmed_version }}
name: ${{ steps.version.outputs.name }}
steps:
- name: Set Version (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo VERSION=${{ inputs.version }} >> $GITHUB_ENV
- name: Set Version (Release Event)
if: github.event_name == 'release'
run: |
echo VERSION=${{ github.event.release.tag_name }} >> $GITHUB_ENV
- name: Unified Version
id: version
run: |
INPUT_NAME=${{ inputs.name }}
if [[ ${INPUT_NAME} == '' ]]; then
echo "Name is empty, using default"
echo "name=mondoo" >> $GITHUB_OUTPUT
else
echo "Name: ${INPUT_NAME}"
echo "name=${INPUT_NAME}" >> $GITHUB_OUTPUT
fi
V=$(echo $VERSION | sed 's/v//')
echo "Version: $V"
echo "version=${V}" >> $GITHUB_OUTPUT
echo "trimmed_version=$(echo ${V} | sed 's/-.*//')" >> $GITHUB_OUTPUT
- name: Ensure version of cnquery and cnspec are available
run: |
curl -sL --head --fail https://github.com/mondoohq/cnquery/releases/download/v${{ steps.version.outputs.version }}/cnquery_${{ steps.version.outputs.version }}_windows_amd64.zip
curl -sL --head --fail https://github.com/mondoohq/cnspec/releases/download/v${{ steps.version.outputs.version }}/cnspec_${{ steps.version.outputs.version }}_windows_amd64.zip
dist-prepare:
name: 'Prepare Distribution for Packaging'
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Binaries
env:
VERSION: ${{ needs.setup.outputs.version }}
run: |
# TODO: We should check the sums here
mkdir -p dist && cd dist
curl -sSL -O https://github.com/mondoohq/cnspec/releases/download/v${VERSION}/cnspec_${VERSION}_windows_amd64.zip
unzip cnspec_${VERSION}_windows_amd64.zip
rm cnspec_${VERSION}_windows_amd64.zip
curl -sSL -O https://github.com/mondoohq/cnquery/releases/download/v${VERSION}/cnquery_${VERSION}_windows_amd64.zip
unzip cnquery_${VERSION}_windows_amd64.zip
rm cnquery_${VERSION}_windows_amd64.zip
ls -lh
- name: Upload Distribution
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
msi-build:
name: 'Packaging: Windows MSI'
runs-on: windows-latest
needs: [ setup, dist-prepare ]
# For Version: ${{ needs.setup.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Distribution
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Setup Certificate
shell: bash
run: |
echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
- name: Set signing variables
shell: bash
run: |
echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV"
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV"
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
echo "SM_CODE_SIGNING_CERT_SHA1_HASH=${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}" >> "$GITHUB_ENV"
echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH
echo "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools" >> $GITHUB_PATH
- name: Setup SSM KSP on windows latest
shell: cmd
run: |
curl --retry 10 --retry-delay 60 -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi
msiexec /i smtools-windows-x64.msi /quiet /qn
smksp_registrar.exe list
smctl.exe keypair ls
C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
smksp_cert_sync.exe
- name: Build and Sign MSI
env:
VERSION: ${{ needs.setup.outputs.trimmed-version }}
run: |
$mondooVersion = ${env:VERSION}
echo "Running build job for version ${mondooVersion}"
Copy-Item .\dist\cnquery.exe .\packages\msi\msi\
Copy-Item .\dist\cnspec.exe .\packages\msi\msi\
Copy-Item .\dist\cnquery.exe .\packages\msi\appx\
Copy-Item .\dist\cnspec.exe .\packages\msi\appx\
# build msi package
echo " - Packaging MSI..."
Set-Location -Path '.\packages\msi\'
./package.ps1 -version $mondooVersion
# sign msi package
echo " - Signing MSI..."
Set-Location -Path '.\..\..'
signtool.exe sign /debug /sha1 ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 .\packages\msi\mondoo.msi
Copy-Item '.\packages\msi\mondoo.msi' '.\dist\'
- name: Dump Signing Log on Failure
if: failure()
run: |
echo "Dumping signing logs..."
gc $home\AppData\Local\Temp\signtool.log
echo "Dumping signing manager logs..."
gc $home\.signingmanager\logs\smctl.log
echo "Dumping signing manager KSP logs..."
gc $home\.signinmanager\logs\smksp.log
echo "Dumping signing manager KSP cert sync logs..."
gc $home\.signingmanager\logs\smksp_cert_sync.log
- name: Cleanup dist before upload
run: |
Remove-Item -Path .\dist\cnquery.exe -Force
Remove-Item -Path .\dist\cnspec.exe -Force
- name: Upload Distribution
uses: actions/upload-artifact@v4
with:
name: msi
path: dist/
publish:
name: 'Publish: Releases'
needs: [setup,msi-build]
if: ${{ ! inputs.skip-publish }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download MSI Package
uses: actions/download-artifact@v4
with:
name: msi
path: dist
- name: Authenticate with Google Cloud
id: gauth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{secrets.GCP_CREDENTIALS}}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
- name: Verify access to release bucket
env:
VERSION: ${{ needs.setup.outputs.version }}
run: |
gsutil ls gs://releases-us.mondoo.io/mondoo
- name: Upload static content to buckets
env:
VERSION: ${{ needs.setup.outputs.version }}
run: |
cd dist
mv mondoo.msi mondoo_${VERSION}_windows_amd64.msi
sha256sum mondoo_${VERSION}_windows_amd64.msi >> checksums.windows.txt
gsutil cp checksums.windows.txt gs://releases-us.mondoo.io/mondoo/${VERSION}/checksums.windows.txt
gsutil cp mondoo_${VERSION}_windows_amd64.msi gs://releases-us.mondoo.io/mondoo/${VERSION}/mondoo_${VERSION}_windows_amd64.msi
- name: Reindex folder on releaser.mondoo.com
uses: peter-evans/repository-dispatch@v3
env:
VERSION: ${{ needs.setup.outputs.version }}
with:
token: ${{ secrets.RELEASR_ACTION_TOKEN }}
repository: "mondoohq/releasr"
event-type: reindex
client-payload: '{
"reindex-path": "mondoo/${{ env.VERSION }}",
"bucket": "releases-us.mondoo.io"
}'
- name: Cleanup
run: |
rm -f "${{ steps.gauth.outputs.credentials_file_path }}"