-
Notifications
You must be signed in to change notification settings - Fork 4
182 lines (158 loc) · 7.21 KB
/
release.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
name: Release
on:
release:
types: [created]
# on:
# push:
# branches:
# - master
# - dev2
jobs:
build:
name: Build CLI
strategy:
matrix:
platform:
- os_name: Linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
package: [libs/cli]
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@master
with:
packages: musl-tools # provides musl-gcc
version: 1.0
- run: sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install clang pkg-config musl-tools -y
if: matrix.platform.os_name == 'Linux-x86_64'
- run: |
mkdir -p /tmp/protoc && cd /tmp/protoc
wget -qO- https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protoc-25.1-linux-x86_64.zip -O temp.zip
unzip temp.zip
sudo unzip -o temp.zip -d "/usr"
sudo chmod 755 /usr/bin/protoc
if: matrix.platform.os_name == 'Linux-x86_64'
- uses: arduino/setup-protoc@v2
with:
version: "24.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
if: matrix.platform.os_name == 'macOS-x86_64'
- uses: jetli/wasm-pack-action@v0.4.0
with:
version: "latest"
- name: Install toolchain if not cross-compiling
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- uses: actions/setup-node@v3
with:
node-version: "20.x"
- uses: ./.github/workflows
id: "linuxBuild"
if: matrix.platform.os_name == 'Linux-x86_64'
- run: rustup target add ${{ matrix.platform.target }}
if: matrix.platform.os_name == 'macOS-x86_64'
- run: yarn install
if: matrix.platform.os_name == 'macOS-x86_64'
- run: yarn build
if: matrix.platform.os_name == 'macOS-x86_64'
- run: cargo build --release --locked --target=${{ matrix.platform.target }}
if: matrix.platform.os_name == 'macOS-x86_64'
- name: Sign Mac OS binary
if: matrix.platform.target == 'x86_64-apple-darwin'
env:
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
run: |
# Turn our base64-encoded certificate back to a regular .p12 file
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
# We need to create a new keychain, otherwise using the certificate will prompt
# with a UI dialog asking for the certificate password, which we can't
# use in a headless CI environment
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
# print for debugging
security find-certificate -a
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime target/${{ matrix.platform.target }}/release/paperclip_cli -v
- name: Notaize Mac OS binary
if: matrix.platform.target == 'x86_64-apple-darwin'
env:
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
run: |
# Store the notarization credentials so that we can prevent a UI password dialog
# from blocking the CI
echo "Create keychain profile"
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
# We can't notarize an app bundle directly, but we need to compress it as an archive.
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
# notarization service
echo "Creating temp notarization archive"
mkdir -p dist
cp target/${{ matrix.platform.target }}/release/paperclip_cli dist
DMG_NAME="${{ matrix.platform.target }}-paperclip_cli.dmg"
hdiutil create $DMG_NAME -ov -volname "RecitalInstall" -fs HFS+ -srcfolder "dist"
ditto -c -k $DMG_NAME "notarization.zip"
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
# characteristics. Visit the Notarization docs for more information and strategies on how to optimize it if
# you're curious
echo "Notarize app"
xcrun notarytool submit "notarization.zip" --keychain-profile "notarytool-profile" --wait
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
# validated by macOS even when an internet connection is not available.
echo "Attach staple"
xcrun stapler staple "$DMG_NAME"
- name: Upload Mac OS binary to release
if: matrix.platform.target == 'x86_64-apple-darwin'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.platform.target }}-paperclip_cli.dmg
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
- name: Compress binaries
if: matrix.platform.os_name != 'macOS-x86_64'
run: tar -czvf ${{ matrix.platform.target }}-paperclip_cli.tar.gz -C target/${{ matrix.platform.target }}/release paperclip_cli
- name: Upload binaries to release
if: matrix.platform.target != 'x86_64-apple-darwin'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.platform.target }}-paperclip_cli.tar.gz
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
publish:
needs: build
name: Publish packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: arduino/setup-protoc@v1
with:
version: "3.x"
- uses: jetli/wasm-pack-action@v0.4.0
with:
version: "latest"
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: yarn install
- run: yarn build
- run: lerna publish from-package --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}