Build and Release #9
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to create release for (e.g., v1.0.0)' | |
| required: true | |
| default: 'v1.0.0' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Make gradlew executable | |
| run: | | |
| chmod +x gradlew | |
| - name: Make scripts executable | |
| run: | | |
| chmod +x scripts/*.sh | |
| - name: Validate Gradle Wrapper | |
| run: | | |
| ./scripts/verify-gradle-wrapper.sh | |
| continue-on-error: true | |
| timeout-minutes: 5 | |
| - name: Retry Gradle Wrapper Validation (if needed) | |
| run: | | |
| echo "Checking if Gradle wrapper validation is needed..." | |
| # If the previous step failed, try a manual validation approach | |
| if [ ! -f "gradle/wrapper/gradle-wrapper.jar.sha256" ]; then | |
| echo "Gradle wrapper checksum missing, generating new one..." | |
| ./scripts/fix-gradle-wrapper.sh | |
| else | |
| echo "Gradle wrapper checksum already exists, continuing..." | |
| fi | |
| continue-on-error: true | |
| - name: Check Gradle Wrapper Validation Result | |
| run: | | |
| if [ ! -f "gradle/wrapper/gradle-wrapper.jar.sha256" ]; then | |
| echo "Gradle wrapper checksum missing, generating new one..." | |
| cd gradle/wrapper | |
| sha256sum gradle-wrapper.jar > gradle-wrapper.jar.sha256 | |
| fi | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| gradle-version: wrapper | |
| - name: Decode Keystore | |
| run: | | |
| echo "${{ secrets.KEY_STORE }}" | base64 --decode > app/keystore.jks | |
| continue-on-error: true | |
| - name: Create keystore properties file | |
| run: | | |
| echo "storePassword=${{ secrets.KEY_STORE_PASSWORD }}" > key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> key.properties | |
| echo "storeFile=keystore.jks" >> key.properties | |
| continue-on-error: true | |
| - name: Build APK | |
| run: | | |
| ./gradlew assembleRelease | |
| - name: Rename APK | |
| run: | | |
| mkdir -p release | |
| cp app/build/outputs/apk/release/app-universal-release.apk release/GNet-universal.apk | |
| - name: Get tag name | |
| id: get_tag | |
| run: | | |
| if [[ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]]; then | |
| TAG_NAME=${{ github.event.inputs.tag }} | |
| else | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| fi | |
| echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
| echo "Tag name: $TAG_NAME" | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| name: Release ${{ env.TAG_NAME }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| release/GNet-universal.apk | |
| body: | | |
| ## GNet Release ${{ env.TAG_NAME }} | |
| ### Download Options | |
| - [Universal APK (all architectures)](https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/GNet-universal.apk) - Larger file size, compatible with all devices |