-
-
Notifications
You must be signed in to change notification settings - Fork 9
137 lines (112 loc) · 4.31 KB
/
macos.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
name: Build for macOS
# Using instructions from
# https://docs.flutter.dev/deployment/macos#create-a-build-archive-with-codemagic-cli-tools
on:
# Enable manual run
workflow_dispatch:
push:
tags:
- '**'
jobs:
get-version:
name: Get version
runs-on: ubuntu-latest
outputs:
buildName: ${{ steps.get_version.outputs.buildName }}
buildNumber: ${{ steps.get_version.outputs.buildNumber }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get version
id: get_version
run: |
# get buildName from pubspec.yaml (before the +)
buildName=$(grep -oP '(?<=version: ).*(?=\+)' pubspec.yaml)
echo "buildName=$buildName" >> $GITHUB_OUTPUT
# get buildNumber from pubspec.yaml (after the +)
buildNumber=$(grep -oP '(?<=version: ).*' pubspec.yaml | grep -oP '(?<=\+).*$')
echo "buildNumber=$buildNumber" >> $GITHUB_OUTPUT
build-macos:
name: Build for macOS
runs-on: macos-latest
needs: get-version
env:
APP_STORE_CONNECT_ISSUER_ID: ${{secrets.APP_STORE_CONNECT_ISSUER_ID}}
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{secrets.APP_STORE_CONNECT_KEY_IDENTIFIER}}
APP_STORE_CONNECT_PRIVATE_KEY: ${{secrets.APP_STORE_CONNECT_PRIVATE_KEY}}
APP_STORE_CERTIFICATE_KEY: ${{secrets.APP_STORE_CERTIFICATE_KEY}}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup cache
uses: actions/cache@v3
with:
path: |
build
key: ${{ runner.OS }}-ricochlime-macos-${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('**/*.dart') }}
restore-keys: |
${{ runner.OS }}-ricochlime-macos-
- name: Remove dev dependencies
run: ./patches/remove_dev_dependencies.sh
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
architecture: x64
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:'
- name: Install Codemagic CLI Tools
run: pipx install codemagic-cli-tools
- name: Setup keychain
run: |
keychain initialize
app-store-connect fetch-signing-files $(xcode-project detect-bundle-id) \
--platform MAC_OS \
--type MAC_APP_STORE \
--certificate-key=@env:APP_STORE_CERTIFICATE_KEY \
--create
app-store-connect certificates list \
--type MAC_INSTALLER_DISTRIBUTION \
--certificate-key=@env:APP_STORE_CERTIFICATE_KEY \
--save
keychain add-certificates
xcode-project use-profiles
- run: flutter pub get
- run: find . -name "Podfile" -execdir pod install \;
- name: Build for macOS
run: |
flutter build macos
- name: Package for App Store
id: package
run: |
APP_NAME="build/macos/Build/Products/Release/Ricochlime.app"
PACKAGE_NAME="build/macos/Build/Products/Release/Ricochlime.pkg"
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_OUTPUT
xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg
INSTALLER_CERT_NAME=$(keychain list-certificates \
| jq '[.[]
| select(.common_name
| contains("Mac Developer Installer"))
| .common_name][0]' \
| xargs)
xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME"
rm -f unsigned.pkg
- name: Compress macOS build
id: compress
run: |
zipName="Ricochlime_v${{ needs.get-version.outputs.buildName }}.app.zip"
echo "zipName=$zipName" >> $GITHUB_OUTPUT
pushd build/macos/Build/Products/Release
zip -r "$zipName" "Ricochlime.app"
popd
- name: Restore keychain
run: |
keychain use-login
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Ricochlime-macOS-Archive
path: build/macos/Build/Products/Release/${{ steps.compress.outputs.zipName }}
- name: Publish to App Store
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: app-store-connect publish --path ${{ steps.package.outputs.PACKAGE_NAME }}