Skip to content

Commit 2854e29

Browse files
authored
CI: add macOS app bundle distribution workflow (#5118)
1 parent 33f29c1 commit 2854e29

File tree

1 file changed

+130
-0
lines changed

1 file changed

+130
-0
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
name: macOS distribute app
3+
4+
# Build and bundle macOS app
5+
6+
on:
7+
workflow_dispatch:
8+
schedule:
9+
# At 07:30 on Thursdays.
10+
# See https://crontab.guru/#30_7_*_*_THU
11+
- cron: "30 7 * * THU"
12+
push:
13+
tags:
14+
- '**'
15+
16+
permissions: {}
17+
18+
env:
19+
KEYCHAIN_PROFILE: notarytool-profile
20+
21+
jobs:
22+
macos_build:
23+
name: macOS distribute
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}-${{
27+
matrix.name }}-${{ matrix.os }}
28+
cancel-in-progress: true
29+
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
name:
34+
- "x86_64"
35+
- "arm64"
36+
include:
37+
- name: "x86_64"
38+
os: macos-13
39+
deployment_target: 10.13
40+
- name: "arm64"
41+
os: macos-14
42+
deployment_target: 11
43+
fail-fast: false
44+
45+
steps:
46+
- name: Info
47+
run: |
48+
echo "macOS version $(sw_vers -productVersion)"
49+
echo "architecture $(uname -a)"
50+
- name: Disabling Spotlight
51+
run: sudo mdutil -a -i off
52+
- name: Uninstalling Homebrew
53+
run: |
54+
echo "Moving directories..."
55+
sudo mkdir /opt/local-off /opt/homebrew-off
56+
test ! -d /usr/local || /usr/bin/sudo /usr/bin/find /usr/local \
57+
-mindepth 1 -maxdepth 1 -type d -print -exec /bin/mv {} \
58+
/opt/local-off/ \;
59+
test ! -d /opt/homebrew || /usr/bin/sudo /usr/bin/find /opt/homebrew \
60+
-mindepth 1 -maxdepth 1 -type d -print -exec /bin/mv {} \
61+
/opt/homebrew-off/ \;
62+
echo "Removing files..."
63+
test ! -d /usr/local || /usr/bin/sudo /usr/bin/find /usr/local \
64+
-mindepth 1 -maxdepth 1 -type f -print -delete
65+
test ! -d /opt/homebrew || /usr/bin/sudo /usr/bin/find /opt/homebrew \
66+
-mindepth 1 -maxdepth 1 -type f -print -delete
67+
# Rehash to forget about the deleted files
68+
hash -r
69+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
70+
- name: Environment info
71+
shell: bash -el {0}
72+
run: |
73+
printenv | sort
74+
75+
- name: Install the Apple certificate and provisioning profile
76+
env:
77+
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
78+
MACOS_PROVISION_PROFILE: ${{ secrets.MACOS_PROVISION_PROFILE }}
79+
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
80+
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
81+
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.MACOS_CI_KEYCHAIN_PWD }}
82+
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
83+
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
84+
MACOS_NOTARIZATION_PWD: ${{ secrets.MACOS_NOTARIZATION_PWD }}
85+
run: |
86+
CERT="$RUNNER_TEMP/certificate.p12"
87+
INTERMEDIATE_CERT="$RUNNER_TEMP/DeveloperIDG2CA.cer"
88+
89+
curl -o "$INTERMEDIATE_CERT" https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
90+
91+
echo -n "$MACOS_CERTIFICATE" | base64 --decode -o "$CERT"
92+
echo -n "$MACOS_PROVISION_PROFILE" | base64 --decode -o "$RUNNER_TEMP/embedded.provisionprofile"
93+
94+
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
95+
security default-keychain -s build.keychain
96+
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
97+
security set-keychain-settings -t 15000
98+
security import "$INTERMEDIATE_CERT" -k build.keychain -T /usr/bin/codesign
99+
security import "$CERT" -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
100+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" \
101+
build.keychain 1> /dev/null
102+
103+
echo "Create keychain profile"
104+
xcrun notarytool store-credentials "$KEYCHAIN_PROFILE" --apple-id "$MACOS_NOTARIZATION_APPLE_ID"\
105+
--team-id "$MACOS_NOTARIZATION_TEAM_ID" --password "$MACOS_NOTARIZATION_PWD"
106+
107+
- name: Create config file
108+
shell: bash -el {0}
109+
env:
110+
Config: ${HOME}/.config/grass/configure-build-${{ matrix.name }}.sh
111+
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
112+
run: |
113+
mkdir -p "${HOME}/.config/grass"
114+
echo sdk=\"$(xcrun --show-sdk-path)\" >> ${{ env.Config }}
115+
echo deployment_target=\"${{ matrix.deployment_target }}\" >> ${{ env.Config }}
116+
echo cs_ident=\"${MACOS_CERTIFICATE_NAME}\" >> ${{ env.Config }}
117+
echo cs_keychain_profile=\"${KEYCHAIN_PROFILE}\" >> ${{ env.Config }}
118+
echo cs_provisionprofile=\"${RUNNER_TEMP}/embedded.provisionprofile\" >> ${{ env.Config }}
119+
120+
- name: Build GRASS GIS app
121+
run: |
122+
./macos/build_grass_app.bash --with-liblas --notarize -o "${{ runner.temp }}"
123+
124+
- name: Upload DMG file as artifact
125+
if: ${{ success() && !cancelled() }}
126+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
127+
with:
128+
name: ${{ env.DMG_NAME }}
129+
path: ${{ env.DMG_FILE }}
130+
retention-days: 3

0 commit comments

Comments
 (0)