Skip to content

Commit c4aceab

Browse files
authored
chore: add macos dmg action (#867)
1 parent d2f1a01 commit c4aceab

File tree

2 files changed

+82
-11
lines changed

2 files changed

+82
-11
lines changed

.github/workflows/cd.yaml

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,79 @@ env:
99
FLUTTER_VERSION: '3.24.x'
1010

1111
jobs:
12-
build_and_publish:
12+
build_and_upload_macos_dmg:
13+
runs-on: macos-latest
14+
env:
15+
MACOS_APP_RELEASE_PATH: build/macos/Build/Products/Release
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 5
20+
- name: Check version in pubspec.yaml
21+
id: check
22+
run: |
23+
changed=$(git diff --unified=0 --merge-base HEAD~ -- 'pubspec.yaml' | grep -n '^@@' | cut -d':' -f1)
24+
if [[ "$changed" == "5" ]]; then
25+
echo "lines=changed" >> "$GITHUB_OUTPUT"
26+
fi
27+
- uses: subosito/flutter-action@v2
28+
if: steps.check.outputs.lines == 'changed'
29+
with:
30+
channel: 'stable'
31+
flutter-version: ${{env.FLUTTER_VERSION}}
32+
- name: Build macOS app
33+
id: buildmacos
34+
if: steps.check.outputs.lines == 'changed'
35+
run: flutter build macos --release
36+
- name: Codesign executable
37+
id: codesignmacos
38+
if: steps.buildmacos.outcome == 'success'
39+
env:
40+
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
41+
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
42+
MACOS_IDENTITY: ${{ secrets.MACOS_IDENTITY }}
43+
run: |
44+
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
45+
echo "Create Keychain"
46+
security create-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
47+
echo "Assign to Login Keychain"
48+
security default-keychain -s build.keychain
49+
echo "Unlock the Login Keychain"
50+
security unlock-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
51+
echo "Import certificate"
52+
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
53+
echo "Set Key Partition"
54+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PWD build.keychain
55+
echo "Sign the app"
56+
/usr/bin/codesign --force --deep -s $MACOS_IDENTITY ./$MACOS_APP_RELEASE_PATH/musicpod.app
57+
- name: Create a dmg
58+
id: createdmg
59+
if: steps.codesignmacos.outcome == 'success'
60+
run: |
61+
echo "Install create-dmg"
62+
brew install create-dmg
63+
cd $MACOS_APP_RELEASE_PATH
64+
create-dmg \
65+
--volname "musicpod" \
66+
--window-pos 200 120 \
67+
--window-size 950 820 \
68+
--icon-size 130 \
69+
--text-size 14 \
70+
--icon "musicpod.app" 260 250 \
71+
--hide-extension "musicpod.app" \
72+
--app-drop-link 540 250 \
73+
--hdiutil-quiet \
74+
"musicpod.dmg" \
75+
"musicpod.app"
76+
- name: Append Asset
77+
if: steps.createdmg.outcome == 'success'
78+
uses: AButler/[email protected]
79+
with:
80+
files: "$MACOS_APP_RELEASE_PATH/musicpod.app"
81+
repo-token: ${{ secrets.GITHUB_TOKEN }}
82+
release-tag: ${{ github.ref_name }}
83+
84+
build_and_publish_snap:
1385
runs-on: ubuntu-latest
1486
outputs:
1587
output1: ${{ steps.check.outputs.lines }}

macos/Runner.xcodeproj/project.pbxproj

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@
268268
33CC10EC2044A3C60003C045 = {
269269
CreatedOnToolsVersion = 9.2;
270270
LastSwiftMigration = 1100;
271-
ProvisioningStyle = Automatic;
272271
SystemCapabilities = {
273272
com.apple.Sandbox = {
274273
enabled = 1;
@@ -568,11 +567,11 @@
568567
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
569568
CLANG_ENABLE_MODULES = YES;
570569
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
571-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
572-
CODE_SIGN_STYLE = Automatic;
570+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "";
571+
CODE_SIGN_STYLE = Manual;
573572
COMBINE_HIDPI_IMAGES = YES;
574573
CURRENT_PROJECT_VERSION = 1;
575-
DEVELOPMENT_TEAM = Y7ZGTYFNR6;
574+
DEVELOPMENT_TEAM = "";
576575
INFOPLIST_FILE = Runner/Info.plist;
577576
INFOPLIST_KEY_CFBundleDisplayName = MusicPod;
578577
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
@@ -701,11 +700,11 @@
701700
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
702701
CLANG_ENABLE_MODULES = YES;
703702
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
704-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
705-
CODE_SIGN_STYLE = Automatic;
703+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "";
704+
CODE_SIGN_STYLE = Manual;
706705
COMBINE_HIDPI_IMAGES = YES;
707706
CURRENT_PROJECT_VERSION = 1;
708-
DEVELOPMENT_TEAM = Y7ZGTYFNR6;
707+
DEVELOPMENT_TEAM = "";
709708
INFOPLIST_FILE = Runner/Info.plist;
710709
INFOPLIST_KEY_CFBundleDisplayName = MusicPod;
711710
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
@@ -728,11 +727,11 @@
728727
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
729728
CLANG_ENABLE_MODULES = YES;
730729
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
731-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
732-
CODE_SIGN_STYLE = Automatic;
730+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "";
731+
CODE_SIGN_STYLE = Manual;
733732
COMBINE_HIDPI_IMAGES = YES;
734733
CURRENT_PROJECT_VERSION = 1;
735-
DEVELOPMENT_TEAM = Y7ZGTYFNR6;
734+
DEVELOPMENT_TEAM = "";
736735
INFOPLIST_FILE = Runner/Info.plist;
737736
INFOPLIST_KEY_CFBundleDisplayName = MusicPod;
738737
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";

0 commit comments

Comments
 (0)