|
9 | 9 | FLUTTER_VERSION: '3.24.x'
|
10 | 10 |
|
11 | 11 | 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 | + |
| 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: |
13 | 85 | runs-on: ubuntu-latest
|
14 | 86 | outputs:
|
15 | 87 | output1: ${{ steps.check.outputs.lines }}
|
|
0 commit comments