Created
February 1, 2021 09:30
-
-
Save salihgueler/f73dcad2f7c9750387b58267d2f7b439 to your computer and use it in GitHub Desktop.
Gist MacOS Deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: On MacOS Deploy | |
'on': | |
push: | |
branches: | |
- "main" | |
jobs: | |
on-push-main: | |
runs-on: macos-latest | |
env: | |
MACOS_APP_RELEASE_PATH: build/macos/Build/Products/Release | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: subosito/flutter-action@v1 | |
with: | |
channel: dev | |
- name: Enable Macos | |
run: flutter config --enable-macos-desktop | |
- name: Build macOS app | |
run: flutter build macos --release | |
- name: Codesign executable | |
env: | |
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} | |
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
run: | | |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12 | |
echo "Create Keychain" | |
security create-keychain -p <YOUR-PASSWORD> build.keychain | |
echo "Assign to Login Keychain" | |
security default-keychain -s build.keychain | |
echo "Unlock the Login Keychain" | |
security unlock-keychain -p <YOUR-PASSWORD> build.keychain | |
echo "Import certificate" | |
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign | |
echo "Set Key Partition" | |
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k <YOUR-PASSWORD> build.keychain | |
echo "Find Identity" | |
security find-identity | |
echo "Sign the app" | |
/usr/bin/codesign --force --deep -s <IDENTITY-ID> ./$MACOS_APP_RELEASE_PATH/<YOUR-APP-NAME>.app | |
- name: Create a dmg | |
run: | | |
echo "Install create-dmg" | |
brew install create-dmg | |
cd $MACOS_APP_RELEASE_PATH | |
create-dmg \ | |
--volname "<YOUR-APP-NAME>" \ | |
--window-pos 200 120 \ | |
--window-size 800 529 \ | |
--icon-size 130 \ | |
--text-size 14 \ | |
--icon "<YOUR-APP-NAME>.app" 260 250 \ | |
--hide-extension "<YOUR-APP-NAME>.app" \ | |
--app-drop-link 540 250 \ | |
--hdiutil-quiet \ | |
"<YOUR-APP-NAME>.dmg" \ | |
"<YOUR-APP-NAME>.app" | |
- name: Create Version Number | |
id: versions | |
run: | | |
git fetch | |
VERSION_WITHOUT_SUFFIX="$(grep 'version:' pubspec.yaml | awk '{ print $2 }' | cut -d'+' -f 1)" | |
function parse_git_hash() { | |
git rev-list --count origin/main | |
} | |
MAIN_COUNT=$(parse_git_hash) | |
APP_VERSION="$VERSION_WITHOUT_SUFFIX+$MAIN_COUNT" | |
echo "::set-output name=version::$(echo $APP_VERSION)" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.versions.outputs.version }} | |
release_name: Release ${{ steps.versions.outputs.version }} | |
body: | | |
Release Notes | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: build/macos/Build/Products/Release/<YOUR-APP-NAME>.dmg | |
asset_name: <YOUR-APP-NAME>.dmg | |
asset_content_type: application/octet-stream |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment