Repository navigation
138 lines (119 loc) · 4.72 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (119 loc) · 4.72 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
138
name: Release
permissions:
contents: write
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Verify release metadata
id: release_metadata
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
VERSION="${TAG_NAME#v}"
if [ -z "$VERSION" ] || [ "$VERSION" = "$TAG_NAME" ]; then
echo "Release tag must start with v, got: $TAG_NAME" >&2
exit 1
fi
VERSION_NAME=$(sed -n 's/^VERSION_NAME=//p' version.properties | tr -d '\r')
if [ -z "$VERSION_NAME" ]; then
echo "VERSION_NAME is missing from version.properties" >&2
exit 1
fi
if [ "$VERSION" != "$VERSION_NAME" ]; then
echo "Tag version $VERSION does not match VERSION_NAME $VERSION_NAME" >&2
exit 1
fi
BODY=$(awk -v ver="$VERSION" '
index($0, "## [" ver "]") == 1 { found=1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md | sed '/./,$!d' | sed -e :a -e '/^[[:space:]]*$/{$d;N;ba}')
if [ -z "$BODY" ]; then
echo "CHANGELOG.md has no entry for version $VERSION" >&2
exit 1
fi
DELIMITER="CHANGELOG_EOF_$(openssl rand -hex 16)"
{
printf 'version=%s\n' "$VERSION"
printf 'changelog<<%s\n' "$DELIMITER"
printf '%s\n' "$BODY"
printf '%s\n' "$DELIMITER"
} >> "$GITHUB_OUTPUT"
- name: Decode production Google Services configuration
env:
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
run: |
test -n "$GOOGLE_SERVICES_JSON_BASE64"
printf '%s' "$GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > app/google-services.json
- name: Verify production Google Services configuration
run: |
set -euo pipefail
readonly EXPECTED_PROJECT_ID="qwelcome-7de54187"
readonly EXPECTED_GOOGLE_APP_ID="1:485478923777:android:351b802ecee6a11d434a00"
PROJECT_ID=$(jq -er '.project_info.project_id' app/google-services.json)
GOOGLE_APP_ID=$(jq -er '
[.client[]
| select(.client_info.android_client_info.package_name == "com.kingpaging.qwelcome")
| .client_info.mobilesdk_app_id]
| if length == 1 then .[0] else error("expected exactly one Android client") end
' app/google-services.json)
test "$PROJECT_ID" = "$EXPECTED_PROJECT_ID"
test "$GOOGLE_APP_ID" = "$EXPECTED_GOOGLE_APP_ID"
./gradlew :app:processReleaseGoogleServices
VALUES_FILE=app/build/generated/res/google-services/release/values/values.xml
test -f "$VALUES_FILE"
grep -Fq ">$PROJECT_ID<" "$VALUES_FILE"
grep -Fq ">$GOOGLE_APP_ID<" "$VALUES_FILE"
- name: Run release verification
run: ./gradlew :app:testDebugUnitTest :app:ktlintCheck :app:detekt :app:lintDebug
- name: Decode keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > qwelcome-release.keystore
ls -la qwelcome-release.keystore
- name: Build signed release APK
run: ./gradlew assembleRelease
env:
KEYSTORE_FILE: qwelcome-release.keystore
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: qwelcome
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Rename APK with version
run: |
VERSION="${{ steps.release_metadata.outputs.version }}"
cp app/build/outputs/apk/release/app-release.apk "QWelcome-v${VERSION}.apk"
ls -lh QWelcome-v${VERSION}.apk
- name: Create Release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
name: Q Welcome v${{ steps.release_metadata.outputs.version }}
draft: false
prerelease: false
files: |
QWelcome-v${{ steps.release_metadata.outputs.version }}.apk
body: |
## Q Welcome v${{ steps.release_metadata.outputs.version }}
${{ steps.release_metadata.outputs.changelog }}
### Installation
1. Download `QWelcome-v${{ steps.release_metadata.outputs.version }}.apk`
2. Enable "Install from unknown sources" on your Android device
3. Install the APK
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}