Update NuGet packages #124
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: main | |
on: | |
push: | |
pull_request: | |
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 | |
jobs: | |
# MAUI Android Build | |
build-android: | |
#runs-on: windows-latest | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_NOLOGO: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
name: Android Build | |
strategy: | |
matrix: | |
rid: | |
- android | |
- android-arm | |
- android-arm64 | |
- android-x86 | |
- android-x64 | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1 | |
- name: Update API | |
run: | | |
sed -i "s|anikin_api_endpoint|${{ secrets.API_URL }}|g" Anikin/Constants.cs | |
- name: Create keystore file | |
run: echo "${{ secrets.KEYSTORE_B64 }}" | base64 -d > $GITHUB_WORKSPACE/signing-key.keystore | |
shell: bash | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Install MAUI Workload | |
#run: dotnet workload install maui --ignore-failed-sources | |
run: dotnet workload install maui-android | |
# Setup JDK and Android SDK on Linux | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 22 | |
distribution: adopt | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
- name: Restore Dependencies | |
run: dotnet restore Anikin/ | |
- name: Publish MAUI Android | |
run: > | |
dotnet publish Anikin/ | |
-c Release | |
-f net8.0-android | |
-p:AndroidKeyStore=true | |
-p:AndroidSigningKeyStore=${{ github.workspace }}/signing-key.keystore | |
-p:AndroidSigningStorePass="${{ secrets.PASSWORD }}" | |
-p:AndroidSigningKeyAlias="DrMedia" | |
-p:AndroidSigningKeyPass="${{ secrets.PASSWORD }}" | |
-p:CSharpier_Bypass=true | |
${{ startsWith(matrix.rid, 'android-') && format('{0} {1}', '--runtime', matrix.rid) || '' }} | |
- name: Rename file | |
run: | | |
set -e | |
mv Anikin/bin/Release/net8.0-android${{ startsWith(matrix.rid, 'android-') && format('{0}{1}', '/', matrix.rid) || '' }}/*.apk Anikin-${{ matrix.rid }}.apk | |
shell: bash | |
- name: Upload artifactss | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Anikin-${{ matrix.rid }} | |
path: Anikin-${{ matrix.rid }}.apk | |
build-windows: | |
runs-on: windows-latest | |
name: Windows Build | |
strategy: | |
matrix: | |
rid: | |
- win10-arm64 | |
- win10-x86 | |
- win10-x64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1 | |
- name: Update API | |
run: | | |
sed -i "s|anikin_api_endpoint|${{ secrets.API_URL }}|g" Anikin/Constants.cs | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Install MAUI Workload | |
run: dotnet workload install maui --ignore-failed-sources | |
- name: Restore Dependencies | |
run: dotnet restore Anikin/ | |
- name: Publish MAUI Windows | |
run: > | |
dotnet publish Anikin/ | |
-c Release | |
-f net8.0-windows10.0.19041.0 | |
-p:RuntimeIdentifierOverride=${{ matrix.rid }} | |
-p:WindowsPackageType=None | |
-o build/windows | |
-p:CSharpier_Bypass=true | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Anikin-${{ matrix.rid }} | |
path: build/windows/ | |
deploy: | |
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | |
needs: [build-android, build-windows] | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: write | |
steps: | |
# Checkout required for running git commands, etc. | |
- name: Checkout | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1 | |
- name: Set variables | |
run: | | |
TAG_NAME="${{ github.ref_name }}" | |
echo $TAG_NAME | |
VERSION="$(echo $TAG_NAME | tr -d v)" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "PACKAGE_NAME=${{ github.event.repository.name }}-$TAG_NAME" >> $GITHUB_ENV | |
echo "WINDOWS_PACKAGE_NAME=${{ github.event.repository.name }}-windows-$TAG_NAME" >> $GITHUB_ENV | |
Prerelease_Param="" | |
if [[ $TAG_NAME == *"-pre"* || $TAG_NAME == *"-beta"* || $TAG_NAME == *"-alpha"* ]]; then | |
Prerelease_Param="--prerelease" | |
fi | |
echo $Prerelease_Param | |
echo "Prerelease_Param=$Prerelease_Param" >> $GITHUB_ENV | |
- name: Download Android artifact | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8 | |
with: | |
name: android-build | |
path: Anikin/Android/ | |
- name: Download Windows artifacts | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8 | |
with: | |
name: windows-ci-build | |
path: build/windows/ | |
- name: Create package | |
# Change into the artifacts directory to avoid including the directory itself in the zip archive | |
working-directory: build/windows/ | |
run: zip -r ../../${{ env.WINDOWS_PACKAGE_NAME }}.zip . | |
- name: Set body | |
run: | | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${GITHUB_REF#refs/*/}) | |
echo "TAG_MESSAGE2<<EOF" >> $GITHUB_ENV | |
echo "$TAG_MESSAGE" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Clean up downloaded artifacts | |
run: | | |
set -e | |
mv Anikin/Android/Anikin.apk ${{ env.PACKAGE_NAME }}.apk | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: > | |
gh release create "${{ github.ref_name }}" | |
"${{ env.PACKAGE_NAME }}.apk" | |
"${{ env.WINDOWS_PACKAGE_NAME }}.zip" | |
--repo "${{ github.event.repository.full_name }}" | |
--title "${{ env.VERSION }}" | |
--notes "${{ env.TAG_MESSAGE2 }}" | |
--verify-tag | |
${{ env.Prerelease_Param }} | |
- name: Delete Old Pre-Releases | |
id: delete-pre-releases | |
uses: sgpublic/delete-release-action@master | |
with: | |
pre-release-drop: true | |
pre-release-keep-count: 3 | |
pre-release-drop-tag: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
notify: | |
needs: deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1 | |
- name: Set variables | |
run: | | |
TAG_NAME="${{ github.ref_name }}" | |
echo "$TAG_NAME" | |
echo "PACKAGE_NAME=${{ github.event.repository.name }}-$TAG_NAME" >> $GITHUB_ENV | |
echo "WINDOWS_PACKAGE_NAME=${{ github.event.repository.name }}-windows-$TAG_NAME" >> $GITHUB_ENV | |
- name: Set variables 2 | |
run: | | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${GITHUB_REF#refs/*/}) | |
# Sanitize content | |
TAG_MESSAGE="${TAG_MESSAGE//'%'/'%25'}" | |
TAG_MESSAGE="${TAG_MESSAGE//$'\n'/'\n'}" | |
TAG_MESSAGE="${TAG_MESSAGE//$'\r'/'\r'}" | |
TAG_MESSAGE="$TAG_MESSAGE" | sed "s/\"/'/g" | |
# End sanitization | |
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV | |
echo "$TAG_MESSAGE" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Notify Discord | |
uses: tyrrrz/action-http-request@v1 | |
with: | |
url: ${{ secrets.DISCORD_WEBHOOK }} | |
method: POST | |
headers: | | |
Content-Type: application/json; charset=UTF-8 | |
body: | | |
{ | |
"username": "Notifications", | |
"avatar_url": "https://raw.githubusercontent.com/${{ github.event.repository.full_name }}/master/favicon.png", | |
"content": "**${{ github.event.repository.name }}** new version released!\nVersion: `${{ github.ref_name }}`\n\n${{ env.RELEASE_BODY }}\n\nDownload for Android: <${{ github.event.repository.html_url }}/releases/download/${{ github.ref_name }}/${{ env.PACKAGE_NAME }}.apk>\nDownload for Windows: <${{ github.event.repository.html_url }}/releases/download/${{ github.ref_name }}/${{ env.WINDOWS_PACKAGE_NAME }}.zip>" | |
} |