-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (86 loc) · 3.05 KB
/
Copy pathrelease.yml
File metadata and controls
104 lines (86 loc) · 3.05 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
name: Release
on:
push:
branches:
- 'v[0-9]+*'
- 'release/**'
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > lenscast-release.jks
- name: Calculate Release Version
id: version
run: |
BRANCH_NAME="${{ github.ref_name }}"
BASE_VERSION=$(echo "$BRANCH_NAME" | grep -oE '(?:^|/)[v]?([0-9]+\.[0-9]+(\.[0-9]+)?)' | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1)
if [ -z "$BASE_VERSION" ]; then BASE_VERSION="1.0.0"; fi
IFS='.' read -r major minor patch <<< "$BASE_VERSION"
minor=${minor:-0}
patch=${patch:-0}
BASE_PREFIX="v${major}.${minor}"
latest_tag=$(git tag -l "${BASE_PREFIX}.*" | sort -V | tail -n 1)
if [ -n "$latest_tag" ]; then
latest_patch=${latest_tag##*.}
new_patch=$((latest_patch + 1))
NEW_TAG="${BASE_PREFIX}.${new_patch}"
NEW_APK_VERSION="${major}.${minor}.${new_patch}"
else
NEW_TAG="${BASE_PREFIX}.${patch}"
NEW_APK_VERSION="${major}.${minor}.${patch}"
fi
echo "Next tag computing to: $NEW_TAG"
echo "Next APK version: $NEW_APK_VERSION"
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
echo "apk_version=$NEW_APK_VERSION" >> $GITHUB_OUTPUT
- name: Build Android App (Release)
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew assembleRelease -PversionName="${{ steps.version.outputs.apk_version }}"
- name: Rename APK Outputs
run: |
shopt -s nullglob
apks=(app/build/outputs/apk/release/*.apk)
if [ ${#apks[@]} -eq 0 ]; then
echo "ERROR: No APK files found"
exit 1
fi
for apk in "${apks[@]}"; do
filename=$(basename "$apk")
new_filename="lenscast-${filename#app-}"
mv "$apk" "$new_filename"
done
- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ steps.version.outputs.tag }}"
name: "Release ${{ steps.version.outputs.tag }}"
files: lenscast-*.apk
generate_release_notes: true