This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (166 loc) · 7.21 KB
/
build_pkg.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
name: Build MacOS Package
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
repository_dispatch:
types: [update]
jobs:
pkg:
name: 'Packaging: Mac'
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set Version (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo VERSION=${{ inputs.version }} >> $GITHUB_ENV
- name: Set Version (Repository Dispatch)
if: github.event_name == 'repository_dispatch'
run: |
echo VERSION=${{ github.event.client_payload.version }} >> $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
echo "Version: $VERSION"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Ensure version of cnquery and cnspec are available
run: |
curl -sL --head --fail https://github.com/mondoohq/cnquery/releases/download/v${VERSION}/cnquery_${VERSION}_darwin_amd64.tar.gz
curl -sL --head --fail https://github.com/mondoohq/cnspec/releases/download/v${VERSION}/cnspec_${VERSION}_darwin_amd64.tar.gz
- name: Setup local keychain for signing certificates
run: |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# Setup Keychain:
security create-keychain -p ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} $KEYCHAIN_PATH
# Import Certificates:
echo "${{ secrets.APPLE_KEYS_PRODUCTSIGN }}" | base64 --decode > $RUNNER_TEMP/AppleKeysProductSign.p12
echo "${{ secrets.APPLE_KEYS_CODESIGN }}" | base64 --decode > $RUNNER_TEMP/AppleKeysCodeSign.p12
security import $RUNNER_TEMP/AppleKeysProductSign.p12 -P ${{ secrets.APPLE_KEYS_PASSWORD }} -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security import $RUNNER_TEMP/AppleKeysCodeSign.p12 -P ${{ secrets.APPLE_KEYS_PASSWORD }} -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
########## Build Package. ##########
- name: Run Mac Packager
env:
APPLE_KEYS_CODESIGN_ID: ${{ secrets.APPLE_KEYS_CODESIGN_ID }}
APPLE_KEYS_PRODUCTSIGN_ID: ${{ secrets.APPLE_KEYS_PRODUCTSIGN_ID }}
PKGNAME: ${{ steps.version.outputs.name }}
run: |
${GITHUB_WORKSPACE}/scripts/mac/build-pkg.sh ${{ steps.version.outputs.version }}
- name: Inspect Distribution
if: ${{ always() }}
run: ls -lhR
########## Sign Package. ##########
- name: Package Sign Sample Package (productsign)
run: |
productsign --sign "${{ secrets.APPLE_KEYS_PRODUCTSIGN_ID }}" dist/${{ steps.version.outputs.name }}-macos-universal-${{ steps.version.outputs.version }}.pkg dist/${{ steps.version.outputs.name }}_${{ steps.version.outputs.version }}_darwin_universal.pkg
########## Sign Package. ##########
- name: "Notarize Signed PKG"
uses: devbotsxyz/xcode-notarize@v1
with:
product-path: dist/${{ steps.version.outputs.name }}_${{ steps.version.outputs.version }}_darwin_universal.pkg
appstore-connect-username: ${{ secrets.APPLE_ACCOUNT_USERNAME }}
appstore-connect-password: ${{ secrets.APPLE_ACCOUNT_PASSWORD }}
primary-bundle-id: 'com.${{ steps.version.outputs.name }}.client'
- name: "Staple Release Build"
uses: devbotsxyz/xcode-staple@v1
with:
product-path: dist/${{ steps.version.outputs.name }}_${{ steps.version.outputs.version }}_darwin_universal.pkg
########## Save Package as Artifact. ##########
- name: Archive Notarized Package
uses: actions/upload-artifact@v3
with:
name: notarized-package
path: dist/${{ steps.version.outputs.name }}_${{ steps.version.outputs.version }}_darwin_universal.pkg
retention-days: 30
publish:
name: 'Publish: Releases'
needs: pkg
if: ${{ ! inputs.skip-publish }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Notarized Package
uses: actions/download-artifact@v3
with:
name: notarized-package
path: dist
- name: Get Version & Checksum
run: |
cd dist
# Ensure we only have a single file
FILES=`ls *.pkg | wc -l`
if [[ $FILES != 1 ]]; then
echo "We have more than one file in the dist folder. This is not expected."
exit 1
fi
# Extract the data we need to upload the package
CHECKSUM=`sha256sum *.pkg`
PKG=`ls *.pkg`
VERSION=`echo $PKG | cut -d_ -f2`
# Persist the variables
echo "CHECKSUM=${CHECKSUM}" >> $GITHUB_ENV
echo "PKG=$PKG" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Authenticate with Google Cloud
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{secrets.GCP_CREDENTIALS}}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
- name: Verify access to release bucket
run: |
gsutil ls gs://releases-us.mondoo.io/mondoo/${VERSION}/checksums.macos.txt
- name: Upload static content to buckets
run: |
cd dist
# Download and re-write the checksum file
gsutil cp gs://releases-us.mondoo.io/mondoo/${VERSION}/checksums.macos.txt checksums.orig
cat checksums.orig | grep -v universal > checksums.macos.txt
echo "${CHECKSUM}" >> checksums.macos.txt
gsutil cp checksums.macos.txt gs://releases-us.mondoo.io/mondoo/${VERSION}/checksums.macos.txt
# Overwrite the Universal Package
gsutil cp ${PKG} gs://releases-us.mondoo.io/mondoo/${VERSION}/${PKG}
- name: Reindex folder on releaser.mondoo.com
uses: peter-evans/repository-dispatch@v2
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: Wait a minute...
run: sleep 60
- name: Trigger Homebrew Generation
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_API_TOKEN }}
repository: "mondoohq/homebrew-mondoo"
event-type: update
client-payload: '{"version": "${{ env.VERSION }}"}'