update #19
This file contains 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: update | |
on: | |
workflow_run: | |
workflows: | |
- "release" | |
types: | |
- completed | |
conclusion: success | |
jobs: | |
update_jira: | |
runs-on: ubuntu-latest | |
outputs: | |
APP_VERSION: ${{ steps.extract_version.outputs.APP_VERSION }} | |
JIRA_ENTRIES: ${{ steps.extract_jira_id.outputs.JIRA_ENTRIES }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Extract app version from gradle.properties | |
id: extract_version | |
run: | | |
APP_VERSION=$(grep VERSION_NAME gradle.properties | cut -d'=' -f2 | tr -d ' ') | |
echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_OUTPUT" | |
- name: get previous release tag | |
id: get_prev_release | |
run: | | |
PREV_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "") | |
echo "PREV_TAG=$PREV_TAG" >> $GITHUB_ENV | |
- name: get commit messages since last release | |
id: get_commit_messages | |
run: | | |
if [[ -z "${{ env.PREV_TAG }}" ]]; then | |
COMMITS=$(git log --pretty=format:"%s" --reverse) | |
else | |
COMMITS=$(git log ${{ env.PREV_TAG }}..HEAD --pretty=format:"%s" --reverse) | |
fi | |
echo "$COMMITS" > commit_messages.txt | |
cat commit_messages.txt | |
- name: get jira and update | |
id: extract_jira_id | |
run: | | |
JIRA_ENTRIES="" | |
while IFS= read -r COMMIT_MSG; do | |
JIRA_IDS=$(echo "$COMMIT_MSG" | grep -oE '#[A-Za-z0-9-]+' | tr -d '#' | sort -u) | |
if [[ -z "$JIRA_IDS" ]]; then | |
echo "❌ No Jira ID found in: $COMMIT_MSG" | |
else | |
echo "✅ Extracted Jira IDs: $JIRA_IDS" | |
fi | |
for JIRA_ID in $JIRA_IDS; do | |
if [[ -n "$JIRA_ID" ]]; then | |
JIRA_RESPONSE=$( | |
curl -X GET "${{ secrets.JIRA_DOMAIN }}/rest/api/2/issue/$JIRA_ID" \ | |
-u "${{ secrets.JIRA_GURI }}:${{ secrets.JIRA_GURI_TOKEN }}" \ | |
-H "Accept: application/json" | |
) | |
echo "$JIRA_RESPONSE" > jira_response.json | |
cat jira_response.json | |
JIRA_TITLE=$(echo "$JIRA_RESPONSE" | jq -r '.fields.summary') | |
JIRA_LINK="${{ secrets.JIRA_DOMAIN }}/browse/$JIRA_ID" | |
JIRA_ENTRIES+="\n- $COMMIT_MSG\n [**$JIRA_TITLE**]($JIRA_LINK)" | |
curl -X POST "${{ secrets.JIRA_DOMAIN }}/rest/api/2/issue/$JIRA_ID/transitions" \ | |
-u "${{ secrets.JIRA_GURI }}:${{ secrets.JIRA_GURI_TOKEN }}" \ | |
-H "Accept: application/json" \ | |
-H "Content-Type: application/json" \ | |
--data '{"transition": {"id": "31"}}' | |
fi | |
done | |
done < commit_messages.txt | |
ENCODED=$(echo "$JIRA_ENTRIES" | base64) | |
echo "JIRA_ENTRIES=$ENCODED" >> "$GITHUB_OUTPUT" | |
- name: Get last release tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
id: get_last_release | |
run: | | |
LATEST_RELEASE=$(gh release list --limit 1 --json tagName -q '.[0].tagName') | |
echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_ENV | |
- name: Update Release Notes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
DECODED=$(echo "$JIRA_TASKS" | base64 -d) | |
RELEASE_NOTES=$(gh release view ${{ env.LATEST_RELEASE }} --json body -q .body) | |
UPDATED_NOTES=$( | |
## Updated Release Notes | |
$RELEASE_NOTES | |
### Jira tasks | |
$DECODED | |
) | |
gh release edit "${{ env.LATEST_RELEASE }}" --notes "$UPDATED_NOTES" | |
fastlane: | |
needs: update_jira | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: setup gradle | |
uses: gradle/gradle-build-action@v3 | |
- name: grant gradlew | |
run: chmod +x gradlew | |
- name: Build AAB | |
run: ./gradlew clean bundleRelease | |
- name: setup ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.3.7 | |
- name: bundle | |
run: bundle install | |
- name: decode firebase json | |
run: echo "${{ secrets.FIREBASE_ADMIN_BASE64 }}" | base64 --decode > app/firebase_admin.json | |
- name: deploy to app distribution | |
run: | | |
export RELEASE_NOTES_DECODED="$(echo "${{ needs.update_jira.outputs.JIRA_ENTRIES }}" | base64 -d)" | |
echo "Decoded release notes: $RELEASE_NOTES_DECODED" | |
FIREBASE_APP_ID="${{ secrets.FIREBASE_APP_ID }}" \ | |
FIREBASE_ADMIN_BASE64="${{ secrets.FIREBASE_ADMIN_BASE64 }}" \ | |
RELEASE_NOTES="$RELEASE_NOTES_DECODED" \ | |
bundle exec fastlane deploy --verbose | |
slack_notification: | |
needs: [fastlane, update_jira] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Slack Notification | |
run: | | |
RELEASE_VERSION="${{ needs.update_jira.outputs.APP_VERSION }}" | |
DECODED=$(echo"${{ needs.update_jira.outputs.JIRA_ENTRIES }}" | base64 -d) | |
echo "Release Version: $RELEASE_VERSION" | |
echo "Jira Tasks: $JIRA_TASKS" | |
SLACK_MESSAGE="🚀 *AOS $RELEASE_VERSION release* \n" | |
SLACK_MESSAGE+="```\n" | |
if [[ -n "$JIRA_TASKS" ]]; then | |
SLACK_MESSAGE+="$JIRA_TASKS\n" | |
else | |
SLACK_MESSAGE+="📝 No Jira tasks linked.\n" | |
fi | |
SLACK_MESSAGE+="```" | |
JSON_PAYLOAD=$(echo "$SLACK_MESSAGE" | jq -R --slurp '{text: .}') | |
curl -X POST ${{ secrets.SLACK_WEBHOOK_URL }} | |
-H 'Content-type: application/json' | |
--data "$JSON_PAYLOAD" |