Skip to content

Commit 2c06c0e

Browse files
committed
add MacOs sign binaries
1 parent 4425b3e commit 2c06c0e

File tree

3 files changed

+203
-21
lines changed

3 files changed

+203
-21
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Notarize Archive or App Bundle
2+
description: Notarize ZIP archives, .app bundles, or other files by creating temporary zip
3+
author: MassaLabs
4+
5+
inputs:
6+
paths:
7+
description: Files to notarize (space separated). If not .zip/.pkg/.dmg, creates temporary zip
8+
required: true
9+
apple-id:
10+
description: Apple ID
11+
required: true
12+
apple-team-id:
13+
description: Team ID
14+
required: true
15+
apple-app-password:
16+
description: App password
17+
required: true
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Check file formats and create temporary zip if needed
23+
run: |
24+
echo "🔍 Checking file formats for notarization..."
25+
temp_zip_created=false
26+
unsupported_files=()
27+
28+
for path in ${{ inputs.paths }}; do
29+
echo "📁 Processing: $path"
30+
31+
# Get file extension (only if it has one)
32+
filename=$(basename "$path")
33+
extension=""
34+
if [[ "$filename" == *.* ]]; then
35+
extension="${filename##*.}"
36+
fi
37+
38+
# Check if file is already in supported format
39+
if [[ "$extension" == "zip" || "$extension" == "pkg" || "$extension" == "dmg" ]]; then
40+
echo "✅ File $path is already in supported format ($extension)"
41+
else
42+
echo "⚠️ File $path has unsupported extension ($extension) or no extension, will add to temporary zip..."
43+
unsupported_files+=("$path")
44+
temp_zip_created=true
45+
fi
46+
done
47+
48+
# Create single temporary zip for all unsupported files
49+
if [[ "$temp_zip_created" == "true" ]]; then
50+
echo "📦 Creating single temporary zip for all unsupported files..."
51+
temp_zip="temp_notarization_package.zip"
52+
53+
# Add all unsupported files to the zip
54+
for file in "${unsupported_files[@]}"; do
55+
echo "📁 Adding to zip: $file"
56+
zip -r "$temp_zip" "$file"
57+
done
58+
59+
echo "TEMP_ZIP_CREATED=true" >> $GITHUB_ENV
60+
echo "TEMP_ZIP_FILE=$temp_zip" >> $GITHUB_ENV
61+
62+
# Store list of unsupported files for later stapling
63+
printf "%s\n" "${unsupported_files[@]}" > unsupported_files_list.txt
64+
fi
65+
shell: bash
66+
67+
- name: Submit packages for notarization
68+
run: |
69+
# Process original supported files
70+
for path in ${{ inputs.paths }}; do
71+
filename=$(basename "$path")
72+
extension=""
73+
if [[ "$filename" == *.* ]]; then
74+
extension="${filename##*.}"
75+
fi
76+
77+
if [[ "$extension" == "zip" || "$extension" == "pkg" || "$extension" == "dmg" ]]; then
78+
echo "📦 Submitting for notarization: $path"
79+
xcrun notarytool submit "$path" \
80+
--apple-id "${{ inputs.apple-id }}" \
81+
--password "${{ inputs.apple-app-password }}" \
82+
--team-id "${{ inputs.apple-team-id }}" \
83+
--wait
84+
fi
85+
done
86+
87+
# Process single temporary zip file if created
88+
if [[ "${{ env.TEMP_ZIP_CREATED }}" == "true" ]]; then
89+
echo "📦 Submitting temporary zip for notarization: ${{ env.TEMP_ZIP_FILE }}"
90+
xcrun notarytool submit "${{ env.TEMP_ZIP_FILE }}" \
91+
--apple-id "${{ inputs.apple-id }}" \
92+
--password "${{ inputs.apple-app-password }}" \
93+
--team-id "${{ inputs.apple-team-id }}" \
94+
--wait
95+
fi
96+
shell: bash
97+
98+
- name: Staple notarization tickets to original files
99+
run: |
100+
# Staple to original supported files (only .pkg and .dmg, not .zip)
101+
for path in ${{ inputs.paths }}; do
102+
filename=$(basename "$path")
103+
extension=""
104+
if [[ "$filename" == *.* ]]; then
105+
extension="${filename##*.}"
106+
fi
107+
108+
if [[ "$extension" == "pkg" || "$extension" == "dmg" ]]; then
109+
echo "📎 Stapling to: $path"
110+
xcrun stapler staple "$path"
111+
xcrun stapler validate "$path"
112+
elif [[ "$extension" == "zip" ]]; then
113+
echo "⚠️ Skipping stapling for zip file: $path (Zip files cannot be stapled)"
114+
elif [[ -z "$extension" ]]; then
115+
echo "⚠️ Skipping stapling for binary: $path (Standalone binaries cannot be stapled)"
116+
fi
117+
done
118+
shell: bash
119+
120+
- name: Clean up temporary files
121+
run: |
122+
rm -f temp_notarization_package.zip unsupported_files_list.txt
123+
shell: bash

.github/actions/sign-macos/action.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sign Multiple Universal macOS Binaries
2+
description: Sign multiple macOS binaries
3+
author: MassaLabs
4+
5+
inputs:
6+
paths:
7+
description: Paths to binaries or app bundles to sign (space-separated)
8+
required: true
9+
certificate-p12-base64:
10+
description: Base64 certificate
11+
required: true
12+
certificate-password:
13+
description: Certificate password
14+
required: true
15+
signing-identity:
16+
description: Signing identity
17+
required: true
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
23+
- name: Import Apple signing certificate
24+
uses: Apple-Actions/import-codesign-certs@v3
25+
with:
26+
p12-file-base64: ${{ inputs.certificate-p12-base64 }}
27+
p12-password: ${{ inputs.certificate-password }}
28+
29+
- name: Sign binaries and app bundles
30+
run: |
31+
echo "🔐 Starting signing process..."
32+
for path in ${{ inputs.paths }}; do
33+
echo "📝 Signing: $path"
34+
codesign --force --options runtime --timestamp \
35+
--sign "${{ inputs.signing-identity }}" "$path"
36+
37+
echo "🔍 Verifying signature for: $path"
38+
codesign --verify --deep --strict --verbose=2 "$path"
39+
done
40+
shell: bash

.github/workflows/cd.yml

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ env:
1212
CARGO_TERM_COLOR: always
1313
RUST_BACKTRACE: full
1414

15+
# Add permissions to access organization secrets
16+
permissions:
17+
contents: write
18+
id-token: write
19+
1520
concurrency:
1621
group: ${{ github.workflow }}-${{ github.ref }}
1722
cancel-in-progress: true
@@ -21,7 +26,7 @@ jobs:
2126
strategy:
2227
matrix:
2328
os: [ubuntu-22.04, macOS-latest, windows-latest]
24-
platform: [x86_64, arm64]
29+
platform: [x86_64]
2530
include:
2631
- os: ubuntu-22.04
2732
platform: x86_64
@@ -71,40 +76,54 @@ jobs:
7176
command: build
7277
args: --profile release_prebuilt --target ${{ matrix.target }}
7378

79+
- name: Set binary paths
80+
shell: bash
81+
run: |
82+
if [[ "${{ matrix.platform }}" == "arm64" ]]
83+
then
84+
echo "MASSA_NODE_PATH=target/${{ matrix.target }}/release_prebuilt/massa-node" >> $GITHUB_ENV
85+
echo "MASSA_CLIENT_PATH=target/${{ matrix.target }}/release_prebuilt/massa-client" >> $GITHUB_ENV
86+
else
87+
echo "MASSA_NODE_PATH=target/release_prebuilt/massa-node" >> $GITHUB_ENV
88+
echo "MASSA_CLIENT_PATH=target/release_prebuilt/massa-client" >> $GITHUB_ENV
89+
fi
90+
91+
92+
- name: Wait for file system locks to clear
93+
if: ${{ runner.os == 'Windows' }}
94+
shell: powershell
95+
run: |
96+
Write-Host "Waiting for file system locks to clear..."
97+
Start-Sleep -Seconds 10
98+
Write-Host "File system ready for signing operations"
99+
74100
- name: Sign windows massa-node binary
75101
if: ${{ runner.os == 'Windows' }}
76-
uses: massalabs/station/.github/actions/sign-file-digicert@7481e2a05af97559568772dad473b923b37fbe34
102+
uses: massalabs/station/.github/actions/sign-file-digicert@413d4c0bbd042d5e797fbb66bcd2c96be5c3e71a
77103
with:
78-
file: ./target/release_prebuilt/massa-node
104+
files: "${{ env.MASSA_NODE_PATH }}.exe ${{ env.MASSA_CLIENT_PATH }}.exe"
79105
SM_API_KEY: ${{ secrets.SM_API_KEY }}
80106
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
81107
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
82108
SM_CERT_FINGERPRINT: ${{ secrets.SM_CERT_FINGERPRINT }}
83109
SM_HOST: ${{ secrets.SM_HOST }}
84110

85-
- name: Sign windows massa-client binary
86-
if: ${{ runner.os == 'Windows' }}
87-
uses: massalabs/station/.github/actions/sign-file-digicert@7481e2a05af97559568772dad473b923b37fbe34
111+
- name: Sign Macos binaries
112+
uses: ./.github/actions/sign-macos
113+
if: ${{ runner.os == 'macOS' }}
88114
with:
89-
file: ./target/release_prebuilt/massa-client
90-
SM_API_KEY: ${{ secrets.SM_API_KEY }}
91-
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
92-
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
93-
SM_CERT_FINGERPRINT: ${{ secrets.SM_CERT_FINGERPRINT }}
94-
SM_HOST: ${{ secrets.SM_HOST }}
115+
paths: "$MASSA_CLIENT_PATH $MASSA_NODE_PATH"
116+
certificate-p12-base64: ${{ secrets.APPLE_CERTIFICATE_P12_BASE64 }}
117+
certificate-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
118+
signing-identity: ${{ vars.APPLE_DEVELOPER_ID_APPLICATION }}
95119

96120
- name: Package
97121
shell: bash
98122
run: |
99123
mkdir massa && cd massa && mkdir massa-node && mkdir massa-client
100-
if [[ "${{ matrix.platform }}" == "arm64" ]]
101-
then
102-
cp -v ../target/${{ matrix.target }}/release_prebuilt/massa-node massa-node/massa-node
103-
cp -v ../target/${{ matrix.target }}/release_prebuilt/massa-client massa-client/massa-client
104-
else
105-
cp -v ../target/release_prebuilt/massa-node massa-node/massa-node
106-
cp -v ../target/release_prebuilt/massa-client massa-client/massa-client
107-
fi
124+
125+
cp -v "../$MASSA_NODE_PATH" massa-node/massa-node
126+
cp -v "../$MASSA_CLIENT_PATH" massa-client/massa-client
108127
cp -rv ../massa-node/config massa-node/config
109128
cp -rv ../massa-node/base_config massa-node/base_config
110129
cp -rv ../massa-node/storage massa-node/storage
@@ -117,7 +136,7 @@ jobs:
117136
else
118137
tar czvf massa_${GITHUB_REF/refs\/tags\//}_${{ matrix.name }} massa
119138
fi
120-
cd -
139+
121140
- name: Upload ${{ matrix.os }}_${{ matrix.platform }} artifacts
122141
uses: actions/upload-artifact@v4
123142
with:

0 commit comments

Comments
 (0)