Commit ca05908
committed
add gemini response
Here is the **full, corrected** `.github/workflows/build-and-release.yml` file.
I have integrated the `myalias` alias and the specific signing parameters required to fix the `KeyPass` error.
**Important:** Before you run this, ensure you have added the `ANDROID_KEYSTORE_BASE64` secret to your GitHub repository settings, as discussed.
```yaml
name: Build and Release
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
# =============================================================================
# Build and Test (runs on every push/PR)
# =============================================================================
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Keystore
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > android.keystore
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Install Android workload
run: dotnet workload install android
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore -p:BuildNumber=${{ github.run_number }}
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
# =============================================================================
# Build Desktop Releases
# =============================================================================
build-desktop:
needs: build-and-test
if: github.event_name == 'push'
strategy:
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
artifact: linux-x64
- os: ubuntu-latest
rid: linux-arm64
artifact: linux-arm64
- os: windows-latest
rid: win-x64
artifact: win-x64
- os: windows-latest
rid: win-arm64
artifact: win-arm64
- os: macos-latest
rid: osx-x64
artifact: osx-x64
- os: macos-latest
rid: osx-arm64
artifact: osx-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Publish
shell: bash
run: |
dotnet publish src/MyDesktopApplication.Desktop/MyDesktopApplication.Desktop.csproj \
--configuration Release \
--runtime ${{ matrix.rid }} \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=false \
-p:BuildNumber=${{ github.run_number }} \
--output ./publish/${{ matrix.artifact }}
- name: Create archive (Unix)
if: runner.os != 'Windows'
run: |
cd ./publish
tar -czvf MyDesktopApplication-${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
- name: Create archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive -Path ./publish/${{ matrix.artifact }}/* -DestinationPath ./publish/MyDesktopApplication-${{ matrix.artifact }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: desktop-${{ matrix.artifact }}
path: |
./publish/*.tar.gz
./publish/*.zip
if-no-files-found: error
# =============================================================================
# Build Android APK (Fixed Signing)
# =============================================================================
build-android:
needs: build-and-test
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Keystore
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > android.keystore
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Android workload
run: dotnet workload install android
- name: Accept Android licenses
run: |
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses || true
- name: Build and Sign Android APK
run: |
dotnet publish src/MyDesktopApplication.Android/MyDesktopApplication.Android.csproj \
--configuration Release \
-p:BuildNumber=${{ github.run_number }} \
--output ./publish/android \
-p:AndroidKeyStore=true \
-p:AndroidSigningKeyStore=../../android.keystore \
-p:AndroidSigningStorePass=${{ secrets.ANDROID_SIGNING_PASSWORD }} \
-p:AndroidSigningKeyPass=${{ secrets.ANDROID_SIGNING_PASSWORD }} \
-p:AndroidSigningKeyAlias=myalias
- name: Find and rename APK
run: |
# Try to find the signed APK first, then fallback to any APK
APK_PATH=$(find ./publish/android -name "*-Signed.apk" | head -1)
if [[ -z "$APK_PATH" ]]; then
APK_PATH=$(find ./publish/android -name "*.apk" | head -1)
fi
if [[ -n "$APK_PATH" ]]; then
cp "$APK_PATH" "./publish/MyDesktopApplication-android-${{ github.run_number }}.apk"
else
echo "No APK found!"
exit 1
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: android-apk
path: ./publish/MyDesktopApplication-android-*.apk
if-no-files-found: error
# =============================================================================
# Create GitHub Release
# =============================================================================
release:
needs: [build-desktop, build-android]
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Prepare release files
run: |
mkdir -p ./release
find ./artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.apk" \) -exec cp {} ./release/ \;
ls -la ./release/
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v1.0.${{ github.run_number }}
name: Release 1.0.${{ github.run_number }}
body: |
## Country Quiz v1.0.${{ github.run_number }}
### Downloads
| Platform | Download |
|----------|----------|
| Windows x64 | `MyDesktopApplication-win-x64.zip` |
| Windows ARM64 | `MyDesktopApplication-win-arm64.zip` |
| Linux x64 | `MyDesktopApplication-linux-x64.tar.gz` |
| Linux ARM64 | `MyDesktopApplication-linux-arm64.tar.gz` |
| macOS x64 (Intel) | `MyDesktopApplication-osx-x64.tar.gz` |
| macOS ARM64 (Apple Silicon) | `MyDesktopApplication-osx-arm64.tar.gz` |
| Android | `MyDesktopApplication-android-${{ github.run_number }}.apk` |
### Android Updates
**Version Code**: ${{ github.run_number }}
This APK has an incrementing version code for easy updates.
draft: false
prerelease: false
files: ./release/*
```1 parent ebb30cc commit ca05908
2 files changed
+345
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
| |||
117 | 114 | | |
118 | 115 | | |
119 | 116 | | |
120 | | - | |
| 117 | + | |
121 | 118 | | |
122 | 119 | | |
123 | 120 | | |
| |||
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
151 | | - | |
| 148 | + | |
152 | 149 | | |
153 | 150 | | |
154 | 151 | | |
155 | 152 | | |
156 | 153 | | |
157 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
| |||
217 | 223 | | |
218 | 224 | | |
219 | 225 | | |
220 | | - | |
221 | 226 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 227 | + | |
231 | 228 | | |
232 | 229 | | |
233 | 230 | | |
0 commit comments