releases #21
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: releases | |
on: | |
workflow_dispatch: | |
env: | |
DOTNET_NOLOGO: true # Disable the .NET logo | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience | |
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry | |
DOTNET_VERSION: '9.0' | |
CSPROJ_PATH: 'src/SwashbucklerDiary.Maui' | |
CSPROJ_FILE_PATH: 'src/SwashbucklerDiary.Maui/SwashbucklerDiary.Maui.csproj' | |
APP_NAME: 'SwashbucklerDiary' | |
STORE_ID: '9P6PBVBF466L' | |
jobs: | |
windowsAndAndroid: | |
runs-on: windows-latest | |
steps: | |
# Checkout the code | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Install .NET SDK | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '${{ env.DOTNET_VERSION }}.x' | |
# Install Java | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'microsoft' | |
java-version: '11' | |
# Install MAUI Workloads | |
- name: Install MAUI Workloads | |
run: | | |
dotnet workload install android --ignore-failed-sources | |
dotnet workload install maui --ignore-failed-sources | |
- name: Restore Dependencies | |
run: dotnet restore ${{ env.CSPROJ_FILE_PATH }} | |
# Get the commit count and format the version | |
- name: Get commit count and format version | |
id: version | |
shell: bash | |
run: | | |
commit_count=$(git rev-list --count HEAD) | |
major=$((commit_count / 1000)) | |
minor=$((commit_count % 1000 / 10)) | |
patch=$((commit_count % 10)) | |
formatted_version="$major.$minor.$patch" | |
echo "APPLICATION_DISPLAY_VERSION=$formatted_version" >> $GITHUB_ENV | |
echo "APPLICATION_VERSION=$commit_count" >> $GITHUB_ENV | |
# Replace the version in the csproj file | |
- name: Version the app | |
uses: managedcode/MAUIAppVersion@v1 | |
with: | |
csproj: ${{ env.CSPROJ_FILE_PATH }} | |
version: ${{ env.APPLICATION_VERSION }} | |
displayVersion: ${{ env.APPLICATION_DISPLAY_VERSION }} | |
# Decode Keystore | |
- name: Decode Keystore | |
id: decode_keystore | |
uses: timheuer/base64-to-file@v1 | |
with: | |
fileDir: ${{ env.CSPROJ_PATH }} | |
fileName: ${{secrets.ANDROIDSIGNINGKEYSTORE}} | |
encodedString: ${{ secrets.KEYSTORE_BASE64 }} | |
# Publish MAUI Android | |
- name: Publish MAUI Android | |
run: dotnet publish ${{ env.CSPROJ_FILE_PATH }} -c:Release -p:AndroidPackageFormat=apk -f:net${{ env.DOTNET_VERSION }}-android -r android-arm64 --sc -p:PublishTrimmed=true -p:AndroidKeyStore=true -p:AndroidSigningKeyStore=${{secrets.ANDROIDSIGNINGKEYSTORE}} -p:AndroidSigningKeyAlias=${{secrets.ANDROIDSIGNINGKEYALIAS}} -p:AndroidSigningKeyPass=${{secrets.ANDROIDSIGNINGKEYPASS}} -p:AndroidSigningStorePass=${{secrets.ANDROIDSIGNINGSTOREPASS}} --no-restore --output Releases | |
- name: Rename apk | |
run: ren Releases/*Signed.apk ${{ env.APP_NAME }}-${{ env.APPLICATION_DISPLAY_VERSION }}-android-arm64.apk | |
# Update to Github Releases | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: 'Releases/${{ env.APP_NAME }}-${{ env.APPLICATION_DISPLAY_VERSION }}-android-arm64.apk' | |
token: ${{ github.token }} | |
name: ${{ env.APPLICATION_DISPLAY_VERSION }} | |
tag: 'v${{ env.APPLICATION_DISPLAY_VERSION }}' | |
prerelease: true | |
# Replace the version in Package.appxmanifest | |
- name: Update version in Package.appxmanifest | |
shell: bash | |
run: | | |
sed -i "s/Version=\"0\.0\.0\.0\"/Version=\"${{ env.APPLICATION_DISPLAY_VERSION }}.0\"/" \ | |
${{ env.CSPROJ_PATH }}/Platforms/Windows/Package.appxmanifest | |
# Publish MAUI Windows | |
- name: Publish MAUI Windows | |
run: dotnet publish ${{ env.CSPROJ_FILE_PATH }} -f net${{ env.DOTNET_VERSION }}-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsAppSDKSelfContained=true --sc -p:WindowsAppSdkDeploymentManagerInitialize=false | |
# Update to Microsoft Store | |
- name: Setup Microsoft Store Developer CLI | |
uses: microsoft/setup-msstore-cli@v1 | |
- name: Configure Microsoft Store Developer CLI | |
run: msstore reconfigure --tenantId ${{ secrets.PARTNER_CENTER_TENANT_ID }} --sellerId ${{ secrets.PARTNER_CENTER_SELLER_ID }} --clientId ${{ secrets.PARTNER_CENTER_CLIENT_ID }} --clientSecret ${{ secrets.PARTNER_CENTER_CLIENT_SECRET }} | |
- name: Update to Microsoft Store | |
run: msstore publish ${{ env.CSPROJ_PATH }} -i ${{ env.CSPROJ_PATH }}/bin/Release/net${{ env.DOTNET_VERSION }}-windows10.0.19041.0/win10-x64/AppPackages -id ${{ env.STORE_ID }} | |
macOSAndiOS: | |
runs-on: macos-latest | |
steps: | |
# Checkout the code | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Update Xcode | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: latest-stable | |
# Install .NET SDK | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '${{ env.DOTNET_VERSION }}.x' | |
# Install MAUI Workloads | |
- name: Install MAUI Workloads | |
run: | | |
dotnet workload install maui --ignore-failed-sources | |
- name: Restore Dependencies | |
run: dotnet restore ${{ env.CSPROJ_FILE_PATH }} | |
# Get the commit count and format the version | |
- name: Get commit count and format version | |
id: version | |
shell: bash | |
run: | | |
commit_count=$(git rev-list --count HEAD) | |
major=$((commit_count / 1000)) | |
minor=$((commit_count % 1000 / 10)) | |
patch=$((commit_count % 10)) | |
formatted_version="$major.$minor.$patch" | |
echo "APPLICATION_DISPLAY_VERSION=$formatted_version" >> $GITHUB_ENV | |
echo "APPLICATION_VERSION=$commit_count" >> $GITHUB_ENV | |
# Replace the version in the csproj file | |
- name: Version the app | |
uses: managedcode/MAUIAppVersion@v1 | |
with: | |
csproj: ${{ env.CSPROJ_FILE_PATH }} | |
version: ${{ env.APPLICATION_VERSION }} | |
displayVersion: ${{ env.APPLICATION_DISPLAY_VERSION }} | |
# Publish MAUI MacCatalyst | |
- name: Publish MAUI MacCatalyst | |
run: | | |
dotnet publish ${{ env.CSPROJ_FILE_PATH }} -f:net${{ env.DOTNET_VERSION }}-maccatalyst -c:Release -p:RuntimeIdentifier=maccatalyst-arm64 --sc -p:PublishTrimmed=true | |
dotnet publish ${{ env.CSPROJ_FILE_PATH }} -f:net${{ env.DOTNET_VERSION }}-maccatalyst -c:Release -p:RuntimeIdentifier=maccatalyst-x64 --sc -p:PublishTrimmed=true | |
- name: Rename pkg | |
run: | | |
mv ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-maccatalyst/maccatalyst-arm64/publish/*.pkg ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-maccatalyst/maccatalyst-arm64/publish/${{ env.APP_NAME }}-${{ env.APPLICATION_DISPLAY_VERSION }}-maccatalys-arm64.pkg | |
mv ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-maccatalyst/maccatalyst-x64/publish/*.pkg ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-maccatalyst/maccatalyst-x64/publish/${{ env.APP_NAME }}-${{ env.APPLICATION_DISPLAY_VERSION }}-maccatalys-x64.pkg | |
# Publish MAUI iOS | |
- name: Publish MAUI iOS | |
run: | | |
dotnet publish ${{ env.CSPROJ_FILE_PATH }} -f:net${{ env.DOTNET_VERSION }}-ios -c:Release -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:EnableCodeSigning=false -p:EnableOnDemandResources=false -p:MtouchUseLlvm=false -p:AotAssemblies=true | |
- name: Rename ipa | |
run: | | |
mv ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-ios/ios-arm64/publish/*.ipa ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-ios/ios-arm64/publish/${{ env.APP_NAME }}-${{ env.APPLICATION_DISPLAY_VERSION }}-ios-arm64.ipa | |
# Update to Github Releases | |
- name: Update maccatalyst-arm64 to Github Releases | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{env.CSPROJ_PATH}}/bin/Release/net${{ env.DOTNET_VERSION }}-maccatalyst/maccatalyst-arm64/publish/*.pkg | |
file_glob: true | |
tag: v${{ env.APPLICATION_DISPLAY_VERSION }} | |
- name: Update maccatalyst-x64 to Github Releases | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.CSPROJ_PATH }}/bin/Release/net${{ env.DOTNET_VERSION }}-maccatalyst/maccatalyst-x64/publish/*.pkg | |
file_glob: true | |
tag: v${{ env.APPLICATION_DISPLAY_VERSION }} | |
- name: Update ios-arm64 to Github Releases | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.CSPROJ_PATH }}/bin/Release/net${{ env.DOTNET_VERSION }}-ios/ios-arm64/publish/*.ipa | |
file_glob: true | |
tag: v${{ env.APPLICATION_DISPLAY_VERSION }} |