forked from MetaCubeX/ClashMetaForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (79 loc) · 3.42 KB
/
release.yml
File metadata and controls
82 lines (79 loc) · 3.42 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
name: Release
on:
workflow_dispatch:
inputs:
release-tag:
description: 'Release Tag (v2.x.x)'
required: true
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Checkout submodules # This is required, don't use submodules flag for actions/checkout instead.
run: git submodule update --init --recursive --force
- uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 21
- uses: gradle/actions/setup-gradle@v6
- uses: actions/setup-go@v6
with:
go-version: "1.26"
check-latest: true # Always check for the latest patch release
- name: Update CA
if: github.repository == 'MetaCubeX/ClashMetaForAndroid'
run: |
sudo apt-get update && sudo apt-get install ca-certificates
sudo update-ca-certificates
cp -f /etc/ssl/certs/ca-certificates.crt core/src/foss/golang/clash/component/ca/ca-certificates.crt
- name: Write signing properties
if: github.repository == 'MetaCubeX/ClashMetaForAndroid'
env:
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: |
touch signing.properties
echo keystore.password="$SIGNING_STORE_PASSWORD" > signing.properties
echo key.alias="$SIGNING_KEY_ALIAS" >> signing.properties
echo key.password="$SIGNING_KEY_PASSWORD" >> signing.properties
- name: Convert and set version env
id: process-version
run: |
VERSION_TAG=${{ inputs.release-tag }}
VERSION_TAG=${VERSION_TAG#v} # remove the 'v' prefix
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_TAG" # split into array
VERSION_CODE=$(printf "%1d%02d%03d" "${VERSION_PARTS[0]}" "${VERSION_PARTS[1]}" "${VERSION_PARTS[2]}")
echo "versonName=$VERSION_TAG" >> $GITHUB_OUTPUT # "1.2.3"
echo "versonCode=$VERSION_CODE" >> $GITHUB_OUTPUT # "102003"
# Re-write version in build.gradle.kts
- name: Re-write version
uses: Devofure/advance-android-version-actions@v1.5
with:
gradlePath: build.gradle.kts
versionCode: ${{ steps.process-version.outputs.versonCode }}
versionName: ${{ steps.process-version.outputs.versonName }}
# If any change found, commit it and push
- name: Commit and push if changes
run: |
changes=$(git diff --name-only origin/main | wc -l)
if [ $changes -gt 0 ]
then
newVersionName=${{ steps.process-version.outputs.versonName }}
newVersionCode=${{ steps.process-version.outputs.versonCode }}
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git add build.gradle.kts
git commit -am "Bump version to $newVersionName ($newVersionCode)"
git push
fi
- name: Build
run: ./gradlew app:assembleMetaRelease
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ inputs.release-tag }} "./app/build/outputs/apk/meta/release/"*.apk --generate-notes