-
Notifications
You must be signed in to change notification settings - Fork 5
152 lines (135 loc) · 5.41 KB
/
build.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
name: Build and package the NowSecure Platform CLI
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches:
- main
workflow_dispatch: {}
jobs:
build-on-ubuntu:
name: Build .deb files for arm & intel
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get Git History
run: git fetch --unshallow --filter=blob:none --tags --force
- name: Set Version
id: set-version
run: |
TAG_REGEX="^refs/tags/(v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)$"
if [[ ${{ github.ref }} =~ $TAG_REGEX ]]; then
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "version=$(git describe --tags --long --match 'v*')" >> $GITHUB_OUTPUT
fi
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: |
sudo apt update && sudo apt install p7zip-full nsis
CLI_VERSION=${{ steps.set-version.outputs.version }} node cli/.ci/set-package-vars.js
CI_CD_BUILD=1 cli/.ci/package.sh
- name: Archive Linux artifacts
uses: actions/upload-artifact@v4
with:
name: Linux
path: |
cli/tmp/artifacts/linux
- name: Archive Windows artifacts
uses: actions/upload-artifact@v4
with:
name: Windows
path: |
cli/tmp/artifacts/windows
build-on-macos:
name: Build, sign and notarize .pkg files for Mac
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Get Git History
run: git fetch --unshallow --filter=blob:none --tags --force
- name: Set Version
id: set-version
run: |
TAG_REGEX="^refs/tags/(v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)$"
if [[ ${{ github.ref }} =~ $TAG_REGEX ]]; then
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "version=$(git describe --tags --long --match 'v*')" >> $GITHUB_OUTPUT
fi
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Build, sign, and notarize the installer packages
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }}
APPLEID: ${{ secrets.APPLEID }}
APPLEID_TEAM: ${{ secrets.APPLEID_TEAM }}
SIGNING_ID: ${{ secrets.SIGNING_ID }}
# Note: oclif requires the env var OSX_KEYCHAIN to know where the keychain is
run: |
CLI_VERSION=${{ steps.set-version.outputs.version }} node cli/.ci/set-package-vars.js
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $OSX_KEYCHAIN
OSX_KEYCHAIN=$RUNNER_TEMP/app-signing.keychain-db CI_CD_BUILD=1 cli/.ci/package.sh
node cli/.ci/notarize.js cli/dist/macos/*.pkg
spctl --assess -vv --type install cli/dist/macos/*.pkg
- name: Clean up keychain
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
- name: Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: MacOS
path: |
cli/dist/macos
release:
needs:
- build-on-ubuntu
- build-on-macos
runs-on: ubuntu-22.04
steps:
- name: Check Tag
id: check-tag
run: |
TAG_REGEX="^refs/tags/(v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)$"
if [[ ${{ github.ref }} =~ $TAG_REGEX ]]; then
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
echo "release=true" >> $GITHUB_OUTPUT
else
echo "release=false" >> $GITHUB_OUTPUT
fi
- name: Download Release Artifacts
if: ${{ steps.check-tag.outputs.release == 'true' }}
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create Release
if: ${{ steps.check-tag.outputs.release == 'true' }}
uses: ncipollo/[email protected]
with:
artifacts: "artifacts/Linux/*.deb,artifacts/MacOS/*.pkg"
tag: ${{ steps.check-tag.outputs.version }}