-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 3.85 KB
/
deploy.yml
File metadata and controls
111 lines (94 loc) · 3.85 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
name: Release Deploy
on:
push:
branches: [ "release/**" ]
env:
ALIAS: release
jobs:
deploy:
environment: Production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: JDK setup
uses: actions/setup-java@v4
with:
java-version: 20
distribution: corretto
cache: gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Derive versionName / versionCode
id: ver
shell: bash
run: |
REF="${GITHUB_REF}" # e.g. refs/heads/release/v0.1.0
if [[ "$REF" == refs/heads/release/* ]]; then
# Extract version string after "release/"
VERSION_TAG="${REF#refs/heads/release/}" # v0.1.0
VERSION_NAME="${VERSION_TAG#v}" # 0.1.0
else
# Non-release branches: snapshot
LAST_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0)"
VERSION_NAME="${LAST_TAG#v}-SNAPSHOT+${GITHUB_SHA::7}"
VERSION_TAG="v${VERSION_NAME%%-*}" # v0.0.0 for reference; won't be used to tag
fi
# Compute a safe, monotonic versionCode
# Prefer SemVer encoding when VERSION_NAME is x.y.z (not snapshot)
BASE_NAME="${VERSION_NAME%%-*}" # strip -SNAPSHOT if present
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_NAME"
if [[ "$MAJOR" =~ ^[0-9]+$ && "$MINOR" =~ ^[0-9]+$ && "$PATCH" =~ ^[0-9]+$ ]]; then
VC=$((10#${MAJOR}*10000 + 10#${MINOR}*100 + 10#${PATCH}))
else
# Fallback for snapshots or odd formats
VC="$(date -u +%Y%m%d%H)"
fi
echo "version_name=$VERSION_NAME" >> "$GITHUB_OUTPUT"
echo "version_code=$VC" >> "$GITHUB_OUTPUT"
echo "version_tag=$VERSION_TAG" >> "$GITHUB_OUTPUT"
echo "Derived VERSION_NAME=$VERSION_NAME"
echo "Derived VERSION_CODE=$VC"
echo "Derived VERSION_TAG=$VERSION_TAG"
- name: Assemble Release Bundle
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
GOOGLE_SERVER_CLIENT_ID: ${{ secrets.GOOGLE_SERVER_CLIENT_ID }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
run: |
./gradlew \
-PVERSION_NAME="${{ steps.ver.outputs.version_name }}" \
-PVERSION_CODE="${{ steps.ver.outputs.version_code }}" \
bundleRelease
- name: Sign Release
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: composeApp/build/outputs/bundle/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ env.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Tag Release
env:
VERSION_TAG: ${{ steps.ver.outputs.version_tag }}
run: |
# Safety: don't recreate if already exists
if git ls-remote --tags origin | grep -q "refs/tags/${VERSION_TAG}$"; then
echo "Tag ${VERSION_TAG} already exists on remote. Skipping."
exit 0
fi
version_name=${VERSION_TAG}
echo "Tagging release with tag $version_name"
git tag $version_name release/$version_name
git push origin --tags
- name: Create service_account.json
run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json
- name: Deploy to production
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: service_account.json
packageName: io.middlepoint.morestuff
releaseFiles: composeApp/build/outputs/bundle/release/composeApp-release.aab
track: internal
status: draft
mappingFile: composeApp/build/outputs/mapping/release/mapping.txt