Skip to content

Commit ca05908

Browse files
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

File tree

2 files changed

+345
-18
lines changed

2 files changed

+345
-18
lines changed

.github/workflows/build-and-release.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: dotnet test --configuration Release --no-build --verbosity normal
4545

4646
# =============================================================================
47-
# Build Desktop Releases (only on push to main/master, not PRs)
47+
# Build Desktop Releases
4848
# =============================================================================
4949
build-desktop:
5050
needs: build-and-test
@@ -75,9 +75,6 @@ jobs:
7575
- name: Checkout
7676
uses: actions/checkout@v4
7777

78-
- name: Setup Keystore
79-
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > android.keystore
80-
8178
- name: Setup .NET
8279
uses: actions/setup-dotnet@v4
8380
with:
@@ -117,7 +114,7 @@ jobs:
117114
if-no-files-found: error
118115

119116
# =============================================================================
120-
# Build Android APK
117+
# Build Android APK (Fixed Signing)
121118
# =============================================================================
122119
build-android:
123120
needs: build-and-test
@@ -148,17 +145,26 @@ jobs:
148145
run: |
149146
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses || true
150147
151-
- name: Build Android APK
148+
- name: Build and Sign Android APK
152149
run: |
153150
dotnet publish src/MyDesktopApplication.Android/MyDesktopApplication.Android.csproj \
154151
--configuration Release \
155152
-p:BuildNumber=${{ github.run_number }} \
156153
--output ./publish/android \
157-
-p:AndroidSigningPassword=${{ secrets.ANDROID_SIGNING_PASSWORD }}
154+
-p:AndroidKeyStore=true \
155+
-p:AndroidSigningKeyStore=../../android.keystore \
156+
-p:AndroidSigningStorePass=${{ secrets.ANDROID_SIGNING_PASSWORD }} \
157+
-p:AndroidSigningKeyPass=${{ secrets.ANDROID_SIGNING_PASSWORD }} \
158+
-p:AndroidSigningKeyAlias=myalias
158159
159160
- name: Find and rename APK
160161
run: |
161-
APK_PATH=$(find ./publish/android -name "*.apk" | head -1)
162+
# Try to find the signed APK first, then fallback to any APK
163+
APK_PATH=$(find ./publish/android -name "*-Signed.apk" | head -1)
164+
if [[ -z "$APK_PATH" ]]; then
165+
APK_PATH=$(find ./publish/android -name "*.apk" | head -1)
166+
fi
167+
162168
if [[ -n "$APK_PATH" ]]; then
163169
cp "$APK_PATH" "./publish/MyDesktopApplication-android-${{ github.run_number }}.apk"
164170
else
@@ -217,17 +223,8 @@ jobs:
217223
| Android | `MyDesktopApplication-android-${{ github.run_number }}.apk` |
218224
219225
### Android Updates
220-
221226
**Version Code**: ${{ github.run_number }}
222-
223-
This APK has an incrementing version code, so installing it will update
224-
the existing app without requiring an uninstall.
225-
226-
For Obtainium users: Point to this repository's releases.
227-
228-
### Changes
229-
230-
See commit history for changes in this release.
227+
This APK has an incrementing version code for easy updates.
231228
draft: false
232229
prerelease: false
233230
files: ./release/*

0 commit comments

Comments
 (0)