mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-27 10:11:48 -04:00
185 lines
5.9 KiB
YAML
185 lines
5.9 KiB
YAML
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-latest
|
|
outputs:
|
|
APP_VERSION_NAME: ${{ steps.get_version_name.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: Determine Version Name from Tag
|
|
id: get_version_name
|
|
run: echo "APP_VERSION_NAME=$(echo ${{ inputs.tag_name }} | sed 's/-.*//' | sed 's/v//')" >> $GITHUB_OUTPUT
|
|
|
|
- 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-latest
|
|
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-latest
|
|
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 <<EOF
|
|
{
|
|
"content": null,
|
|
"embeds": [
|
|
{
|
|
"title": "🚀 New Android Release: $VERSION",
|
|
"description": "A new build has been promoted to the **$TRACK** track.",
|
|
"color": 5763719,
|
|
"fields": [
|
|
{
|
|
"name": "Track",
|
|
"value": "$TRACK",
|
|
"inline": true
|
|
},
|
|
{
|
|
"name": "Version",
|
|
"value": "$VERSION",
|
|
"inline": true
|
|
}
|
|
],
|
|
"url": "https://github.com/meshtastic/Meshtastic-Android/releases/tag/$VERSION"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
)
|
|
|
|
curl -H "Content-Type: application/json" -d "$PAYLOAD" "$DISCORD_WEBHOOK"
|