Skip to content

Commit 4be026f

Browse files
committed
ci(macOS): Publish daily build artifacts to the server
1 parent fd49001 commit 4be026f

File tree

2 files changed

+85
-25
lines changed

2 files changed

+85
-25
lines changed

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

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
# if [ "${{ inputs.DAILY }}" = "false" ]; then
2+
# FIXME: When triggered by a push event, the DAILY value was not set, so I temporarily set the condition like in the code above.
3+
14
name: Notarize the app (macOS)
25

36
inputs:
47
APPLE_ID:
58
required: true
69
APPLE_PW:
710
required: true
11+
DAILY:
12+
type: boolean
13+
required: false
814
DEV_ID:
915
required: true
1016
KEYCHAIN_PATH:
@@ -89,12 +95,19 @@ runs:
8995
done
9096
9197
- name: Copy the icon file to the app bundle
98+
env:
99+
DAILY: ${{ inputs.DAILY }}
92100
shell: bash
93101
run: |
94102
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
95103
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
96-
cp installer/macos/macapp.icns "$TARGET/Contents/Resources/"
97-
/usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp.icns" "$TARGET/Contents/Info.plist"
104+
if [ "${{ inputs.DAILY }}" = "" ] || [ "${{ inputs.DAILY }}" = "false" ]; then
105+
cp installer/macos/macapp.icns "$TARGET/Contents/Resources/"
106+
/usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp.icns" "$TARGET/Contents/Info.plist"
107+
else
108+
cp installer/macos/macapp-nightly.icns "$TARGET/Contents/Resources/"
109+
/usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp-nightly.icns" "$TARGET/Contents/Info.plist"
110+
fi
98111
done
99112
100113
- name: Sign the manually added extensions.
@@ -114,23 +127,47 @@ runs:
114127
shell: bash
115128
run: mv build/*.app installer/macos
116129

130+
# TODO: I originally tried to break it into two steps to make it more readable,
131+
# but Composite Actions do not support if statements for steps.
132+
# For more information, see https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md
117133
- name: Create the DMG
118134
env:
135+
DAILY: ${{ inputs.DAILY }}
119136
DEV_ID: ${{ inputs.DEV_ID }}
120137
shell: bash
121138
run: |
139+
export DATE=$(date +%Y%m%d)
140+
122141
if [ "${{ inputs.SQLCIPHER }}" = "1" ]; then
123-
sed -i "" 's/"DB Browser for SQLCipher Nightly.app"/"DB Browser for SQLCipher-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/sqlcipher-nightly.json
124-
TARGET="DB Browser for SQLCipher-dev-$(git rev-parse --short --verify HEAD).dmg"
125-
appdmg --quiet installer/macos/sqlcipher-nightly.json "$TARGET"
126-
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
127-
codesign -vvv --deep --strict --verbose=4 "$TARGET"
142+
if [ "${{ inputs.DAILY }}" = "" ] || [ "${{ inputs.DAILY }}" = "false" ]; then
143+
# Continuous with SQLCipher
144+
sed -i "" 's/"DB Browser for SQLCipher Nightly.app"/"DB Browser for SQLCipher-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/sqlcipher-nightly.json
145+
TARGET="DB.Browser.for.SQLCipher-dev-$(git rev-parse --short --verify HEAD).dmg"
146+
appdmg --quiet installer/macos/sqlcipher-nightly.json "$TARGET"
147+
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
148+
codesign -vvv --deep --strict --verbose=4 "$TARGET"
149+
else
150+
# Daily with SQLCipher
151+
TARGET="DB.Browser.for.SQLCipher-universal_$DATE.dmg"
152+
appdmg --quiet installer/macos/sqlcipher-nightly.json "$TARGET"
153+
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
154+
codesign -vvv --deep --strict --verbose=4 "$TARGET"
155+
fi
128156
else
129-
sed -i "" 's/"DB Browser for SQLite Nightly.app"/"DB Browser for SQLite-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/nightly.json
130-
TARGET="DB Browser for SQLite-dev-$(git rev-parse --short --verify HEAD).dmg"
131-
appdmg --quiet installer/macos/nightly.json "$TARGET"
132-
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
133-
codesign -vvv --deep --strict --verbose=4 "$TARGET"
157+
if [ "${{ inputs.DAILY }}" = "" ] || [ "${{ inputs.DAILY }}" = "false" ]; then
158+
# Continuous without SQLCipher
159+
sed -i "" 's/"DB Browser for SQLite Nightly.app"/"DB Browser for SQLite-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/nightly.json
160+
TARGET="DB.Browser.for.SQLite-dev-$(git rev-parse --short --verify HEAD).dmg"
161+
appdmg --quiet installer/macos/nightly.json "$TARGET"
162+
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
163+
codesign -vvv --deep --strict --verbose=4 "$TARGET"
164+
else
165+
# Daily without SQLCipher
166+
TARGET="DB.Browser.for.SQLite-universal_$DATE.dmg"
167+
appdmg --quiet installer/macos/nightly.json "$TARGET"
168+
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
169+
codesign -vvv --deep --strict --verbose=4 "$TARGET"
170+
fi
134171
fi
135172
136173
- name: Notarize the dmg
@@ -139,16 +176,8 @@ runs:
139176
APPLE_PW: ${{ inputs.APPLE_PW }}
140177
TEAM_ID: ${{ inputs.TEAM_ID }}
141178
shell: bash
142-
run: |
143-
for TARGET in $(find . -name "DB Browser for SQL*.dmg" | sed -e 's/ /_/g'); do
144-
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
145-
xcrun notarytool submit "$TARGET" --apple-id "$APPLE_ID" --password "$APPLE_PW" --team-id "$TEAM_ID" --wait
146-
done
179+
run: xcrun notarytool submit *.dmg --apple-id "$APPLE_ID" --password "$APPLE_PW" --team-id "$TEAM_ID" --wait
147180

148181
- name: Staple the notarization ticket
149182
shell: bash
150-
run: |
151-
for TARGET in $(find . -name "DB Browser for SQL*.dmg" | sed -e 's/ /_/g'); do
152-
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
153-
xcrun stapler staple "$TARGET"
154-
done
183+
run: xcrun stapler staple *.dmg

.github/workflows/build-macos.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
- cron: '0 0 * * *' # Every day at midnight (UTC)
66
workflow_call:
77
workflow_dispatch:
8+
inputs:
9+
assume-triggerd-by-schedule:
10+
description: 'Assume this workflow was triggered by the schedule'
11+
required: false
12+
type: boolean
813

914
permissions:
1015
contents: write
@@ -18,11 +23,14 @@ jobs:
1823
matrix:
1924
os: [macos-13-runner]
2025
sqlcipher: ["0", "1"]
26+
env:
27+
DAILY: ${{ github.event.name == 'schedule' || github.event.inputs.assume-triggerd-by-schedule }}
2128
steps:
2229
- name: Checkout
2330
uses: actions/checkout@v3
2431

25-
- name: Configure build
32+
- if: github.event_name != 'schedule' && env.DAILY != 'true'
33+
name: Configure build (Continuous)
2634
run: |
2735
if [ "${{ matrix.sqlcipher }}" = "1" ]; then
2836
sed -i "" 's/"DB Browser for SQLite"/"DB Browser for SQLCipher-dev-'$(git rev-parse --short --verify HEAD)'"/' CMakeLists.txt
@@ -32,6 +40,17 @@ jobs:
3240
mkdir build && cd build
3341
cmake -G Ninja -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DcustomTap=1 -Dsqlcipher=${{ matrix.sqlcipher }} ..
3442
43+
- if: github.event_name == 'schedule' || env.DAILY == 'true'
44+
name: Configure build (Daily)
45+
run: |
46+
if [ "${{ matrix.sqlcipher }}" = "1" ]; then
47+
sed -i "" 's/"DB Browser for SQLite"/"DB Browser for SQLCipher Nightly"/' CMakeLists.txt
48+
else
49+
sed -i "" 's/"DB Browser for SQLite"/"DB Browser for SQLite Nightly"/' CMakeLists.txt
50+
fi
51+
mkdir build && cd build
52+
cmake -G Ninja -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DcustomTap=1 -Dsqlcipher=${{ matrix.sqlcipher }} ..
53+
3554
- name: Build
3655
working-directory: ./build
3756
run: ninja
@@ -51,18 +70,30 @@ jobs:
5170
with:
5271
APPLE_ID: ${{ secrets.MACOS_CODESIGN_APPLE_ID }}
5372
APPLE_PW: ${{ secrets.MACOS_CODESIGN_APPLE_PW }}
73+
DAILY: ${{ env.DAILY }}
5474
DEV_ID: ${{ secrets.MACOS_CODESIGN_DEV_ID }}
5575
KEYCHAIN_PATH: ${{ secrets.MACOS_CODESIGN_KEYCHAIN_PATH }}
5676
KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_KEYCHAIN_PW }}
5777
SQLCIPHER: ${{ matrix.sqlcipher }}
5878
TEAM_ID: ${{ secrets.MACOS_CODESIGN_TEAM_ID }}
5979

60-
- if: github.event_name != 'pull_request' && github.event_name != 'schedule'
80+
- if: github.event_name != 'pull_request' && github.event_name != 'schedule' && env.DAILY != 'true'
6181
name: Release (Continuous)
6282
uses: softprops/action-gh-release@v1
6383
with:
6484
files: DB\ Browser\ for\ *.dmg
6585
prerelease: true
6686
tag_name: continuous
6787

68-
# TODO: - if: github.event_name == 'schedule'
88+
- if: github.event_name == 'schedule' || env.DAILY == 'true'
89+
name: Release (Daily)
90+
run: |
91+
export DATE=$(date +%Y%m%d)
92+
rsync -aP *.dmg ${{ secrets.MACOS_BUILD_ARTIFACTS_UPLOAD_TARGET }}:/nightlies/macos-universal/
93+
if [ "${{ matrix.sqlcipher }}" = "1" ]; then
94+
ssh -q ${{ secrets.MACOS_BUILD_ARTIFACTS_UPLOAD_TARGET }} "cd /nightlies/latest && rm -f *SQLC*-universal*dmg*"
95+
ssh -q ${{ secrets.MACOS_BUILD_ARTIFACTS_UPLOAD_TARGET }} "ln -s /nightlies/macos-universal/DB.Browser.for.SQLCipher-universal_$DATE.dmg /nightlies/latest/DB.Browser.for.SQLCipher-universal.dmg"
96+
else
97+
ssh -q ${{ secrets.MACOS_BUILD_ARTIFACTS_UPLOAD_TARGET }} "cd /nightlies/latest && rm -f *SQLi*-universal*dmg*"
98+
ssh -q ${{ secrets.MACOS_BUILD_ARTIFACTS_UPLOAD_TARGET }} "ln -s /nightlies/macos-universal/DB.Browser.for.SQLite-universal_$DATE.dmg /nightlies/latest/DB.Browser.for.SQLite-universal.dmg"
99+
fi

0 commit comments

Comments
 (0)