-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (113 loc) · 4.71 KB
/
android_deploy_prod.yml
File metadata and controls
137 lines (113 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Android Deploy Prod
on:
workflow_dispatch:
permissions:
contents: write
jobs:
deploy_prod:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
echo "${{ secrets.KEYSTORE }}" > keystore.jks.asc
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSPHRASE }}" --batch keystore.jks.asc > keystore.jks
- name: Update Version
run: bash ./.github/scripts/update_versions.sh
- name: Read version from toml
id: version
run: |
VERSION_NAME=$(awk -F '"' '/versionName = "/{print $2}' gradle/libs.versions.toml)
VERSION_CODE=$(awk -F '"' '/versionCode = "/{print $2}' gradle/libs.versions.toml)
echo "name=$VERSION_NAME" >> "$GITHUB_OUTPUT"
echo "code=$VERSION_CODE" >> "$GITHUB_OUTPUT"
- name: Get previous release tag
id: prev_tag
run: |
PREV_TAG=$(git describe --tags --abbrev=0 --match="release-*" 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
# If no previous release tag, use first commit
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "tag=$PREV_TAG" >> "$GITHUB_OUTPUT"
echo "Previous tag: $PREV_TAG"
- name: Generate changelogs
env:
VERSION_CODE: ${{ steps.version.outputs.code }}
run: |
FROM_TAG="${{ steps.prev_tag.outputs.tag }}"
TO_TAG="${{ github.sha }}"
# Generate Play Store changelog
bash ./.github/scripts/generate_changelog.sh "$FROM_TAG" "$TO_TAG" play "$VERSION_CODE"
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Cache Ruby - Bundler
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant Permission to Execute
run: chmod +x gradlew
- name: Use CI-optimized Gradle properties
run: cp .github/properties/gradle-ci.properties gradle.properties
- name: Use CI-optimized Convention Gradle properties
run: cp .github/properties/gradle-convention-ci.properties build-logic/gradle.properties
- name: Install bundle
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Configure Keystore
env:
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
run: |
echo "storeFile=keystore.jks" >> keystore.properties
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> keystore.properties
echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> keystore.properties
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> keystore.properties
- name: Create Google Play Config file
env:
PLAY_CONFIG_JSON: ${{ secrets.PLAY_CONFIG_JSON }}
run: |
echo "$PLAY_CONFIG_JSON" > play_config.json.b64
base64 -d -i play_config.json.b64 > play_config.json
- name: Create Google Services Config file
env:
GOOGLE_SERVICES_JSON_STORE: ${{ secrets.GOOGLE_SERVICES_JSON_STORE }}
run: |
echo "$GOOGLE_SERVICES_JSON_STORE" > app/store/google-services.json.b64
base64 -d -i app/store/google-services.json.b64 > app/store/google-services.json
- name: Distribute app to Prod track 🚀
run: bundle exec fastlane deploy
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -a -m "release: v${{ steps.version.outputs.name }} (code ${{ steps.version.outputs.code }})" || echo "No changes to commit"
# Create an annotated tag for this release
TAG_NAME="release-v${{ steps.version.outputs.name }}"
# Avoid failure if tag already exists in repo history
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists; skipping create"
else
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PUSH_TOKEN }}
branch: ${{ github.ref }}
tags: true