Build and Release Qama #39
Workflow file for this run
This file contains hidden or 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: Build and Release Qama | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| beta: | |
| type: boolean | |
| description: "Is this a beta release?" | |
| default: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: true | |
| android: false | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| docker-images: true | |
| swap-storage: true | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| version: '3.38.9' # Use specific stable version that meets requirements | |
| cache: true | |
| # Running sync script to ensure no broken dependencies before building | |
| - name: Run Environment Sync | |
| run: | | |
| if [ -f "scripts/fix_environment.sh" ]; then | |
| chmod +x scripts/fix_environment.sh | |
| ./scripts/fix_environment.sh | |
| else | |
| echo "Sync script not found, skipping..." | |
| fi | |
| - name: Extract Version | |
| id: extract_version | |
| run: | | |
| # Generate version dynamically: YY.M.0 format (semantic versioning) | |
| YEAR=$(date +'%y') | |
| MONTH=$(date +'%-m') | |
| VERSION="$YEAR.$MONTH.0" | |
| # Generate build number: YYMMDDHH format | |
| BUILD_NUMBER=$(date +'%y%m%d%H') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| echo "beta=${{ github.event.inputs.beta }}" >> $GITHUB_OUTPUT | |
| - name: Decode Keystore | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: | | |
| echo "${KEYSTORE_BASE64}" | base64 -d > android/upload-keystore.jks | |
| chmod 600 android/upload-keystore.jks | |
| echo "Keystore decoded and permissions set" | |
| - name: Create key.properties | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| run: | | |
| echo 'storePassword="${KEYSTORE_PASSWORD}"' > android/key.properties | |
| echo 'keyPassword="${KEY_PASSWORD}"' >> android/key.properties | |
| echo 'keyAlias="${KEY_ALIAS}"' >> android/key.properties | |
| echo 'storeFile=../upload-keystore.jks' >> android/key.properties | |
| chmod 600 android/key.properties | |
| echo "Created keystore properties file with restricted permissions" | |
| - name: Verify Keystore | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| run: | | |
| ls -la android/upload-keystore.jks | |
| file android/upload-keystore.jks | |
| if ! keytool -list -v -keystore android/upload-keystore.jks -storepass "${KEYSTORE_PASSWORD}" 2>/dev/null; then | |
| echo "ERROR: Keystore verification failed - aborting build" | |
| exit 1 | |
| fi | |
| echo "Keystore verification successful" | |
| - name: Build APKs | |
| run: | | |
| flutter build apk --flavor normal --release --obfuscate --split-debug-info=build/debug-info --build-name="${{ steps.extract_version.outputs.version }}" --build-number="${{ steps.extract_version.outputs.build_number }}" | |
| flutter build apk --flavor fdroid -t lib/main_fdroid.dart --release --obfuscate --split-debug-info=build/debug-info --build-name="${{ steps.extract_version.outputs.version }}" --build-number="${{ steps.extract_version.outputs.build_number }}" | |
| - name: Save APKs as Artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: updatium-v${{ steps.extract_version.outputs.version }}-run${{ github.run_number }} | |
| path: build/app/outputs/flutter-apk/*.apk | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ steps.extract_version.outputs.tag }} | |
| name: "Updatium Qama ${{ steps.extract_version.outputs.version }}${{ github.event.inputs.beta == 'true' && ' (Beta)' || '' }}" | |
| prerelease: ${{ github.event.inputs.beta == true }} | |
| draft: true | |
| files: build/app/outputs/flutter-apk/*.apk | |
| generate_release_notes: true | |
| - name: Cleanup signing files | |
| if: always() | |
| run: | | |
| echo "Starting cleanup of sensitive signing files..." | |
| # Cleanup keystore file | |
| if [ -f "$GITHUB_WORKSPACE/android/upload-keystore.jks" ]; then | |
| rm -f "$GITHUB_WORKSPACE/android/upload-keystore.jks" || echo "WARNING: Failed to delete keystore file" | |
| if [ -f "$GITHUB_WORKSPACE/android/upload-keystore.jks" ]; then | |
| echo "ERROR: Keystore file still exists after cleanup attempt" | |
| else | |
| echo "Successfully deleted keystore file" | |
| fi | |
| else | |
| echo "Keystore file not found, nothing to cleanup" | |
| fi | |
| # Cleanup key.properties file | |
| if [ -f "$GITHUB_WORKSPACE/android/key.properties" ]; then | |
| rm -f "$GITHUB_WORKSPACE/android/key.properties" || echo "WARNING: Failed to delete key.properties file" | |
| if [ -f "$GITHUB_WORKSPACE/android/key.properties" ]; then | |
| echo "ERROR: key.properties file still exists after cleanup attempt" | |
| else | |
| echo "Successfully deleted key.properties file" | |
| fi | |
| else | |
| echo "key.properties file not found, nothing to cleanup" | |
| fi | |
| # Unset environment variables | |
| unset KEYSTORE_PASSWORD || echo "WARNING: Failed to unset KEYSTORE_PASSWORD" | |
| unset KEY_PASSWORD || echo "WARNING: Failed to unset KEY_PASSWORD" | |
| unset KEY_ALIAS || echo "WARNING: Failed to unset KEY_ALIAS" | |
| unset KEYSTORE_PASS || echo "WARNING: Failed to unset KEYSTORE_PASS" | |
| echo "Cleanup completed" |