-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (118 loc) · 4.11 KB
/
Copy pathrelease-apk.yml
File metadata and controls
135 lines (118 loc) · 4.11 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
name: Release Android APK
on:
workflow_dispatch:
inputs:
bump:
description: Version change for this release (prefer patch/minor; major is a breaking jump)
required: true
type: choice
default: patch
options:
- patch
- minor
- major
- none
# "none" = keep current app.json version (already bumped locally)
notes:
description: Optional release notes for users (shown on the GitHub Release page). Leave blank to use auto notes from commits.
required: false
type: string
default: ''
concurrency:
group: release-android
cancel-in-progress: false
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v4
- name: Accept Android licenses
run: yes | sdkmanager --licenses >/dev/null || true
- name: Install dependencies
run: npm ci
- name: Bump version
if: inputs.bump != 'none'
run: node scripts/bump-version.cjs "${{ inputs.bump }}"
- name: Resolve version
id: meta
run: |
VERSION=$(node -p "require('./app.json').expo.version")
CODE=$(node -p "require('./app.json').expo.android.versionCode")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "version_code=$CODE" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "Resolved v$VERSION (versionCode $CODE)"
- name: Prebuild Android project
env:
CI: 1
NODE_ENV: production
run: npx expo prebuild -p android
- name: Build release APK
working-directory: android
env:
NODE_ENV: production
run: ./gradlew assembleRelease --no-daemon
- name: Package APK artifact
run: |
mkdir -p dist
cp android/app/build/outputs/apk/release/app-release.apk dist/Canal-Study.apk
ls -lh dist/Canal-Study.apk
- name: Write release notes file
env:
MANUAL_NOTES: ${{ inputs.notes }}
run: |
{
if [ -n "$MANUAL_NOTES" ]; then
printf '%s\n\n' "$MANUAL_NOTES"
fi
echo "### Install"
echo "Download **Canal-Study.apk** below and install it on your Android device."
echo ""
echo "Version **${{ steps.meta.outputs.version }}** (versionCode ${{ steps.meta.outputs.version_code }})."
} > dist/release-notes.md
cat dist/release-notes.md
- name: Commit version bump and create tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add app.json package.json
if ! git diff --cached --quiet; then
git commit -m "Release Canal Study v${{ steps.meta.outputs.version }}"
git push origin HEAD:${{ github.ref_name }}
fi
if git rev-parse "${{ steps.meta.outputs.tag }}" >/dev/null 2>&1; then
echo "Tag ${{ steps.meta.outputs.tag }} already exists"
else
git tag "${{ steps.meta.outputs.tag }}"
git push origin "${{ steps.meta.outputs.tag }}"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: Canal Study ${{ steps.meta.outputs.tag }}
body_path: dist/release-notes.md
generate_release_notes: true
files: dist/Canal-Study.apk
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}