name: Promote Release on: workflow_call: inputs: base_version: description: 'The base version for the release (e.g., 2.3.0)' required: true type: string tag_name: description: 'The tag that triggered the release' required: true type: string release_name: description: 'The desired name for the GitHub release' required: true type: string final_tag: description: 'The final tag for the release' required: true type: string commit_sha: description: 'The commit SHA to tag' required: false type: string channel: description: 'The channel to promote to' required: true type: string from_channel: description: 'The channel to promote from' required: true type: string secrets: GSERVICES: required: true KEYSTORE: required: true KEYSTORE_FILENAME: required: true KEYSTORE_PROPERTIES: required: true DATADOG_APPLICATION_ID: required: true DATADOG_CLIENT_TOKEN: required: true GOOGLE_MAPS_API_KEY: required: true GOOGLE_PLAY_JSON_KEY: required: true GRADLE_ENCRYPTION_KEY: required: true DISCORD_WEBHOOK_ANDROID: required: false concurrency: group: ${{ github.workflow }}-${{ inputs.tag_name }} cancel-in-progress: true permissions: contents: write pull-requests: read id-token: write attestations: write jobs: prepare-build-info: runs-on: ubuntu-24.04-arm outputs: APP_VERSION_NAME: ${{ steps.prep_version.outputs.APP_VERSION_NAME }} APP_VERSION_CODE: ${{ steps.calculate_version_code.outputs.versionCode }} steps: - name: Checkout code uses: actions/checkout@v6 with: ref: ${{ inputs.commit_sha || inputs.tag_name }} fetch-depth: 0 submodules: 'recursive' - name: Prep APP_VERSION_NAME id: prep_version env: INPUT_TAG_NAME: ${{ inputs.tag_name }} run: | VERSION_NAME=$(echo $INPUT_TAG_NAME | sed 's/-.*//' | sed 's/v//') echo "APP_VERSION_NAME=$VERSION_NAME" >> $GITHUB_OUTPUT echo "Parsed Version: $VERSION_NAME" - name: Extract VERSION_CODE_OFFSET from config.properties id: get_version_code_offset run: | OFFSET=$(grep '^VERSION_CODE_OFFSET=' config.properties | cut -d'=' -f2) echo "VERSION_CODE_OFFSET=$OFFSET" >> $GITHUB_OUTPUT - name: Calculate Version Code from Git Commit Count id: calculate_version_code run: | COMMIT_COUNT=$(git rev-list --count HEAD) OFFSET=${{ steps.get_version_code_offset.outputs.VERSION_CODE_OFFSET }} VERSION_CODE=$((COMMIT_COUNT + OFFSET)) echo "versionCode=$VERSION_CODE" >> $GITHUB_OUTPUT shell: bash promote-release: runs-on: ubuntu-24.04-arm environment: Release needs: [ prepare-build-info ] steps: - name: Promote to next channel uses: kevin-david/promote-play-release@v1.2.0 with: service-account-json-raw: ${{ secrets.GOOGLE_PLAY_JSON_KEY }} package-name: 'com.geeksville.mesh' from-track: ${{ inputs.from_channel == 'closed' && 'NewAlpha' || (inputs.from_channel == 'open' && 'beta' || 'internal') }} to-track: ${{ inputs.channel == 'closed' && 'NewAlpha' || (inputs.channel == 'open' && 'beta' || 'production') }} user-fraction: ${{ (inputs.channel == 'production' && '0.1') || (inputs.channel == 'open' && '0.5') || '1.0' }} update-github-release: runs-on: ubuntu-24.04-arm needs: [ prepare-build-info, promote-release ] steps: - name: Checkout code uses: actions/checkout@v6 with: ref: ${{ inputs.commit_sha || inputs.tag_name }} fetch-depth: 0 submodules: 'recursive' - name: Push Git Tag on Success if: ${{ inputs.commit_sha != '' }} run: | git tag ${{ inputs.final_tag }} ${{ inputs.commit_sha }} git push origin ${{ inputs.final_tag }} - name: Update GitHub Release with gh CLI env: GH_TOKEN: ${{ github.token }} run: | gh release edit ${{ inputs.tag_name }} \ --tag ${{ inputs.final_tag }} \ --title "${{ inputs.release_name }} (${{ needs.prepare-build-info.outputs.APP_VERSION_CODE }})" \ --prerelease=${{ inputs.channel != 'production' }} - name: Notify Discord if: ${{ inputs.channel != 'internal' }} env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_ANDROID }} VERSION: ${{ inputs.final_tag }} CHANNEL: ${{ inputs.channel }} run: | if [[ -z "$DISCORD_WEBHOOK" ]]; then echo "No Discord webhook provided. Skipping notification." exit 0 fi # Determine Track Name for Display if [ "$CHANNEL" == "closed" ]; then TRACK="Alpha (Closed)"; fi if [ "$CHANNEL" == "open" ]; then TRACK="Beta (Open)"; fi if [ "$CHANNEL" == "production" ]; then TRACK="Production"; fi # Construct JSON Payload PAYLOAD=$(cat <