-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (93 loc) · 3.11 KB
/
Copy pathrelease-apk.yml
File metadata and controls
108 lines (93 loc) · 3.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
name: Release Android APK
on:
workflow_dispatch:
inputs:
bump:
description: Version change for this release
required: true
type: choice
default: patch
options:
- patch
- minor
- major
- none
# "none" = keep current app.json version (already bumped locally)
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@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- 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
run: npx expo prebuild -p android --non-interactive
- name: Build release APK
working-directory: android
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: 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 "chore: release 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@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: Canal Study ${{ steps.meta.outputs.tag }}
generate_release_notes: true
files: dist/Canal-Study.apk
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}