Created
January 13, 2023 03:56
-
-
Save anggoran/3bbe36e18c58657f475d92e744b57f84 to your computer and use it in GitHub Desktop.
Github Actions code for releasing Windows & MacOS app to Github Release (and Supabase)
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: Release App | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
windows: | |
runs-on: windows-latest | |
steps: | |
- name: Git Checkout | |
uses: actions/checkout@v3 | |
- name: Install yq | |
run: choco install yq | |
- name: Apply Flutter Environment | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Enable Windows | |
run: flutter config --enable-windows-desktop | |
- name: Get Dependencies | |
run: flutter pub get | |
- name: Run Integration Test | |
run: flutter test -d windows integration_test/main.dart | |
- name: Generate App Version | |
id: app_version | |
run: echo "value=$(yq '.version' pubspec.yaml)" >> $env:GITHUB_OUTPUT | |
- name: Activate Packaging Tool | |
run: dart pub global activate flutter_distributor | |
- name: Make a .exe | |
run: flutter_distributor release --name release --jobs release-windows | |
- name: Get App Name | |
id: app_name | |
run: echo "value=$('${{ vars.APP_NAME }}-windows-v${{ steps.app_version.outputs.value }}.exe')" >> $env:GITHUB_OUTPUT | |
- name: Get App Location | |
id: app_location | |
run: echo "value=$('dist/${{ steps.app_version.outputs.value }}/${{ steps.app_name.outputs.value }}')" >> $env:GITHUB_OUTPUT | |
- name: Create Windows Key | |
run: | | |
Set-Content -Path .\key.txt -Value ${{ secrets.WINDOWS_KEY }} | |
openssl base64 -A -d -in key.txt -out dsa_priv.pem | |
- name: Get Windows Signature | |
id: windows_signature | |
run: echo "value=$(flutter pub run auto_updater:sign_update ${{ steps.app_location.outputs.value }})" >> $env:GITHUB_OUTPUT | |
- name: Clean Windows Key | |
run: | | |
Remove-Item -Path .\dsa_priv.pem | |
Remove-Item -Path .\key.txt | |
- name: Upload App to Supabase Storage | |
shell: bash | |
env: | |
AUTH: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
curl -X POST 'https://${{ vars.SUPABASE_ID }}.supabase.co/storage/v1/object/public/client/windows/${{ steps.app_name.outputs.value }}' \ | |
-H "Authorization: Bearer $AUTH" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary "@${{ steps.app_location.outputs.value }}" | |
- name: Get App Public Link | |
id: windows_url | |
run: echo "value=$('https://${{ vars.SUPABASE_ID }}.supabase.co/storage/v1/object/public/public/client/windows/${{ steps.app_name.outputs.value }}')" >> $env:GITHUB_OUTPUT | |
- name: Upsert Appcast | |
shell: bash | |
env: | |
AUTH: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
curl -X POST 'https://${{ vars.SUPABASE_ID }}.supabase.co/rest/v1/apps' \ | |
-H "apikey: $AUTH" \ | |
-H "Authorization: Bearer $AUTH" \ | |
-H "Content-Type: application/json" \ | |
-H "Prefer: resolution=merge-duplicates" \ | |
--data-raw ' | |
{ | |
"version": "${{ steps.app_version.outputs.value }}", | |
"windows_url": "${{ steps.windows_url.outputs.value }}", | |
"windows_signature": "${{ steps.windows_signature.outputs.value }}" | |
} | |
' | |
- name: Github Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.app_version.outputs.value }} | |
files: ${{ steps.app_location.outputs.value }} | |
macos: | |
runs-on: macos-latest | |
steps: | |
- name: Git Checkout | |
uses: actions/checkout@v3 | |
- name: Install appdmg | |
run: npm install -g appdmg | |
- name: Apply Flutter Environment | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Enable MacOS | |
run: flutter config --enable-macos-desktop | |
- name: Get Dependencies | |
run: flutter pub get | |
- name: Run Integration Test | |
run: flutter test -d macos integration_test/main.dart | |
- name: Generate App Version | |
id: app_version | |
run: echo "value=$(yq '.version' pubspec.yaml)" >> $GITHUB_OUTPUT | |
- name: Activate Packaging Tool | |
run: dart pub global activate flutter_distributor | |
- name: Make a .dmg | |
run: flutter_distributor release --name release --jobs release-macos | |
- name: Get App Name | |
id: app_name | |
run: echo "value=${{ vars.APP_NAME }}-macos-v${{ steps.app_version.outputs.value }}.dmg" >> $GITHUB_OUTPUT | |
- name: Get App Location | |
id: app_location | |
run: echo "value=dist/${{ steps.app_version.outputs.value }}/${{ steps.app_name.outputs.value }}" >> $GITHUB_OUTPUT | |
- name: Create MacOS Key | |
run: echo ${{ secrets.MACOS_KEY }} > ./key.txt | |
- name: Get MacOS Signature | |
id: macos_signature | |
run: | | |
raw="$(flutter pub run auto_updater:sign_update ${{ steps.app_location.outputs.value }} --ed-key-file ./key.txt)" | |
IFS=' ' | |
IFS='"' | |
read -a array <<< "$raw" | |
echo "value=${array[1]}" >> $GITHUB_OUTPUT | |
- name: Clean MacOS Key | |
run: rm ./key.txt | |
- name: Upload App to Supabase Storage | |
shell: bash | |
env: | |
AUTH: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
curl -X POST 'https://${{ vars.SUPABASE_ID }}.supabase.co/storage/v1/object/public/client/macos/${{ steps.app_name.outputs.value }}' \ | |
-H "Authorization: Bearer $AUTH" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary "@${{ steps.app_location.outputs.value }}" | |
- name: Get App Public Link | |
id: macos_url | |
run: echo "value=https://${{ vars.SUPABASE_ID }}.supabase.co/storage/v1/object/public/public/client/macos/${{ steps.app_name.outputs.value }}" >> $GITHUB_OUTPUT | |
- name: Upsert Appcast | |
shell: bash | |
env: | |
AUTH: ${{ secrets.SUPABASE_KEY }} | |
run: | | |
curl -X POST 'https://${{ vars.SUPABASE_ID }}.supabase.co/rest/v1/apps' \ | |
-H "apikey: $AUTH" \ | |
-H "Authorization: Bearer $AUTH" \ | |
-H "Content-Type: application/json" \ | |
-H "Prefer: resolution=merge-duplicates" \ | |
--data-raw ' | |
{ | |
"version": "${{ steps.app_version.outputs.value }}", | |
"macos_url": "${{ steps.macos_url.outputs.value }}", | |
"macos_signature": "${{ steps.macos_signature.outputs.value }}" | |
} | |
' | |
- name: Github Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.app_version.outputs.value }} | |
files: ${{ steps.app_location.outputs.value }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment