Update #8
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: | |
branches: [ master ] | |
paths-ignore: | |
- '**/*.md' | |
- '**/*.gitignore' | |
- '**/*.gitattributes' | |
pull_request: | |
branches: [ master ] | |
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 | |
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 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cook KeyStore | |
run: echo "${{ secrets.KEYSTORE_B64 }}" | base64 -d > $GITHUB_WORKSPACE/signing-key.keystore | |
shell: bash | |
- name: Install .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 7.0.x | |
- name: Install MAUI Workload | |
run: dotnet workload install maui --ignore-failed-sources | |
- name: Restore Dependencies | |
run: dotnet restore Yosu/ | |
- name: Publish MAUI Android | |
run: > | |
dotnet publish Yosu/ | |
-c Release | |
-f net7.0-android | |
-p:AndroidKeyStore=true | |
-p:AndroidSigningKeyStore=${{ github.workspace }}/signing-key.keystore | |
-p:AndroidSigningStorePass="${{ secrets.PASSWORD }}" | |
-p:AndroidSigningKeyAlias="YosuAlias" | |
-p:AndroidSigningKeyPass="${{ secrets.PASSWORD }}" | |
- name: Rename file | |
run: | | |
set -e | |
mv Yosu/bin/Release/net7.0-android/com.berry.yosu-Signed.apk Yosu.apk | |
shell: bash | |
- name: Upload Android Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Yosu | |
path: Yosu.apk | |
deploy: | |
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | |
needs: build-android | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: write | |
steps: | |
# Checkout required for running git commands, etc. | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set package name env var | |
run: | | |
TAG_NAME="${{ github.ref_name }}" | |
TAG_NAME="$(echo $TAG_NAME | tr -d v)" | |
echo $TAG_NAME | |
echo "PACKAGE_NAME=${{ github.event.repository.name }}-$TAG_NAME.apk" >> $GITHUB_ENV | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: Yosu | |
path: Yosu | |
- 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: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: > | |
gh release create "${{ github.ref_name }}" | |
"Yosu.apk" | |
--repo "${{ github.event.repository.full_name }}" | |
--title "${{ github.ref_name }}" | |
--notes "${{ env.TAG_MESSAGE2 }}" | |
--verify-tag | |
notify: | |
needs: deploy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set package name env var | |
run: | | |
TAG_NAME="${{ github.ref_name }}" | |
TAG_NAME="$(echo $TAG_NAME | tr -d v)" | |
echo "$TAG_NAME" | |
echo "PACKAGE_NAME=${{ github.event.repository.name }}-$TAG_NAME.zip" >> $GITHUB_ENV | |
- name: Set release body env var | |
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="$(echo $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: <${{ github.event.repository.html_url }}/download/${{ github.ref_name }}/${{ env.PACKAGE_NAME }}>" | |
} |