Skip to content

Commit 042302e

Browse files
ImmaZoninazar-pc
andauthored
Added Windows & macOS Codesigning to Snapshot Build (#258)
* Added Windows & macOS Codesigning & notarization to Snapshot Build Co-Authored-By: Nazar Mokrynskyi <[email protected]>
1 parent 729d274 commit 042302e

File tree

2 files changed

+80
-22
lines changed

2 files changed

+80
-22
lines changed

Diff for: .github/workflows/rust.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ jobs:
5454
os:
5555
- ubuntu-20.04
5656
- macos-11
57-
- windows-2019
5857
- windows-2022
5958

6059
runs-on: ${{ matrix.os }}
@@ -116,7 +115,6 @@ jobs:
116115
os:
117116
- ubuntu-20.04
118117
- macos-11
119-
- windows-2019
120118
- windows-2022
121119

122120
runs-on: ${{ matrix.os }}

Diff for: .github/workflows/snapshot-build.yml

+80-20
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ jobs:
4949
5050
- name: Generate testnet chain specifications
5151
run: |
52-
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain testnet > chain-spec.json
53-
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain testnet --raw > chain-spec-raw.json
52+
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain testnet > chain-spec-${{ github.ref_name }}.json
53+
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain testnet --raw > chain-spec-raw-${{ github.ref_name }}.json
5454
if: matrix.image == 'node'
5555

5656
- name: Upload testnet chain specifications to artifacts
5757
uses: actions/upload-artifact@v2
5858
with:
5959
name: chain-specifications
6060
path: |
61-
chain-spec.json
62-
chain-spec-raw.json
61+
chain-spec-${{ github.ref_name }}.json
62+
chain-spec-raw-${{ github.ref_name }}.json
6363
if-no-files-found: error
6464
if: matrix.image == 'node'
6565

@@ -68,7 +68,7 @@ jobs:
6868
env:
6969
GITHUB_TOKEN: ${{ github.token }}
7070
with:
71-
asset_paths: '["chain-spec.json", "chain-spec-raw.json"]'
71+
asset_paths: '["chain-spec-${{ github.ref_name }}.json", "chain-spec-raw-${{ github.ref_name }}.json"]'
7272
if: matrix.image == 'node'
7373

7474
executables:
@@ -77,13 +77,15 @@ jobs:
7777

7878
strategy:
7979
matrix:
80-
os:
81-
- ubuntu-20.04
82-
- macos-11
83-
- windows-2019
84-
- windows-2022
80+
build:
81+
- os: ubuntu-20.04
82+
suffix: ubuntu-x86_64-${{ github.ref_name }}
83+
- os: macos-11
84+
suffix: macos-x86_64-${{ github.ref_name }}
85+
- os: windows-2022
86+
suffix: windows-x86_64-${{ github.ref_name }}
8587

86-
runs-on: ${{ matrix.os }}
88+
runs-on: ${{ matrix.build.os }}
8789

8890
steps:
8991
- name: Checkout
@@ -94,14 +96,24 @@ jobs:
9496
uses: ilammy/msvc-dev-cmd@v1
9597
with:
9698
toolset: 14.29
97-
if: matrix.os == 'windows-2022'
99+
if: matrix.build.os == 'windows-2022'
98100

99101
- name: Download testnet chain specifications from artifacts
100102
uses: actions/download-artifact@v2
101103
with:
102104
name: chain-specifications
103105
path: .
104106

107+
- name: Rename chain spec file (Linux or macOS)
108+
run: |
109+
mv chain-spec-${{ github.ref_name }}.json chain-spec.json
110+
if: runner.os == 'Linux' || runner.os == 'macOS'
111+
112+
- name: Rename chain spec file (Windows)
113+
run: |
114+
move chain-spec-${{ github.ref_name }}.json chain-spec.json
115+
if: runner.os == 'Windows'
116+
105117
- name: Rust toolchain
106118
uses: actions-rs/toolchain@v1
107119
# TODO: Below can be removed when https://github.com/actions-rs/toolchain/issues/126 is resolved
@@ -123,28 +135,76 @@ jobs:
123135
uses: actions-rs/cargo@v1
124136
with:
125137
command: build
126-
args: --profile production --bins --features=subspace-node/json-chain-spec,subspace-farmer/cuda
138+
args: --profile production --bin subspace-node --bin subspace-farmer --features=subspace-node/json-chain-spec,subspace-farmer/cuda
127139
if: runner.os == 'Linux' || runner.os == 'Windows'
128140

129141
- name: Build (macOS without CUDA)
130142
uses: actions-rs/cargo@v1
131143
with:
132144
command: build
133-
args: --profile production --bins --features=subspace-node/json-chain-spec
145+
args: --profile production --bin subspace-node --bin subspace-farmer --features=subspace-node/json-chain-spec
134146
if: runner.os == 'macOS'
135147

136-
- name: Prepare executables for uploading (Linux or macOS)
148+
- name: Sign Application (macOS)
149+
run: |
150+
echo "Importing certificate"
151+
echo "${{ secrets.MACOS_CERTIFICATE }}" | base64 --decode > certificate.p12
152+
security create-keychain -p "${{ secrets.MACOS_CERTIFICATE_PW }}" build.keychain
153+
security default-keychain -s build.keychain
154+
security unlock-keychain -p "${{ secrets.MACOS_CERTIFICATE_PW }}" build.keychain
155+
security import certificate.p12 -k build.keychain -P "${{ secrets.MACOS_CERTIFICATE_PW }}" -T /usr/bin/codesign
156+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.MACOS_CERTIFICATE_PW }}" build.keychain
157+
echo "Signing farmer"
158+
codesign --force --options=runtime -s "${{ secrets.MACOS_IDENTITY }}" --timestamp target/production/subspace-farmer
159+
echo "Signing node"
160+
codesign --force --options=runtime -s "${{ secrets.MACOS_IDENTITY }}" --timestamp target/production/subspace-node
161+
echo "Creating an archive"
162+
mkdir target/production/macos-binaries
163+
cp target/production/subspace-farmer target/production/subspace-node target/production/macos-binaries
164+
ditto -c -k --rsrc target/production/macos-binaries subspace-binaries.zip
165+
echo "Notarizing"
166+
xcrun altool --notarize-app --primary-bundle-id binaries-${{ github.ref_name }} --username "${{ secrets.MACOS_APPLE_ID}}" --password "${{ secrets.MACOS_APP_PW }}" --file subspace-binaries.zip
167+
# TODO: Wait for notarization before stapling
168+
# echo "Stapling farmer"
169+
# xcrun stapler staple target/production/subspace-farmer
170+
# echo "Stapling node"
171+
# xcrun stapler staple target/production/subspace-node
172+
echo "Done!"
173+
if: runner.os == 'macOS'
174+
175+
- name: Sign Application (Windows)
176+
uses: skymatic/[email protected]
177+
with:
178+
certificate: '${{ secrets.WINDOWS_CERTIFICATE }}'
179+
password: '${{ secrets.WINDOWS_CERTIFICATE_PW }}'
180+
certificatesha1: '00A427587B911908F59B6C42BA2863109C599C1C'
181+
folder: 'target/production'
182+
if: runner.os == 'Windows'
183+
184+
- name: Prepare executables for uploading Linux
137185
run: |
138186
mkdir executables
139-
mv target/production/subspace-node executables/subspace-node-x86_64-${{ matrix.os }}-${{ github.ref_name }}
140-
mv target/production/subspace-farmer executables/subspace-farmer-x86_64-${{ matrix.os }}-${{ github.ref_name }}
141-
if: runner.os == 'Linux' || runner.os == 'macOS'
187+
mv target/production/subspace-farmer executables/subspace-farmer-${{ matrix.build.suffix }}
188+
mv target/production/subspace-node executables/subspace-node-${{ matrix.build.suffix }}
189+
if: runner.os == 'Linux'
190+
191+
- name: Prepare executables for uploading macOS
192+
run: |
193+
mkdir executables
194+
mv target/production/subspace-farmer executables/subspace-farmer-${{ matrix.build.suffix }}
195+
mv target/production/subspace-node executables/subspace-node-${{ matrix.build.suffix }}
196+
# Zip it so that signature is not lost
197+
ditto -c -k --rsrc executables/subspace-farmer-${{ matrix.build.suffix }} executables/subspace-farmer-${{ matrix.build.suffix }}.zip
198+
ditto -c -k --rsrc executables/subspace-node-${{ matrix.build.suffix }} executables/subspace-node-${{ matrix.build.suffix }}.zip
199+
rm executables/subspace-farmer-${{ matrix.build.suffix }}
200+
rm executables/subspace-node-${{ matrix.build.suffix }}
201+
if: runner.os == 'macOS'
142202

143203
- name: Prepare executables for uploading (Windows)
144204
run: |
145205
mkdir executables
146-
move target/production/subspace-node.exe executables/subspace-node-x86_64-${{ matrix.os }}-${{ github.ref_name }}.exe
147-
move target/production/subspace-farmer.exe executables/subspace-farmer-x86_64-${{ matrix.os }}-${{ github.ref_name }}.exe
206+
move target/production/subspace-farmer.exe executables/subspace-farmer-${{ matrix.build.suffix }}.exe
207+
move target/production/subspace-node.exe executables/subspace-node-${{ matrix.build.suffix }}.exe
148208
if: runner.os == 'Windows'
149209

150210
- name: Upload node and farmer executables to assets

0 commit comments

Comments
 (0)