forked from xuhaoyang/ClashForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
133 lines (114 loc) · 4.47 KB
/
build-release.yaml
File metadata and controls
133 lines (114 loc) · 4.47 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
name: Build Release
on:
workflow_dispatch:
inputs:
release-tag:
description: 'Release Tag (v2.x.x)'
required: true
jobs:
BuildRelease:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout submodules
run: git submodule update --init --recursive --force
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Setup Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-download-base-url: 'https://github.com/MetaCubeX/go/releases/download/build'
go-version: '1.26'
- name: Apply Patches
run: |
cd $(go env GOROOT)
for p in $GITHUB_WORKSPACE/.github/patch/*.patch; do patch --verbose -p 1 < "$p"; done
- uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- 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 tag "v$newVersionName"
git push --follow-tags
fi
- name: Update CA
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: Signing properties
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
echo "cat signing.properties"
cat signing.properties
- name: Release Build
if: success()
run: ./gradlew --no-daemon app:assembleMetaRelease
- name: Tag Repo
uses: richardsimko/update-tag@v1
with:
tag_name: ${{ inputs.release-tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release
uses: softprops/action-gh-release@v1
if: ${{ success() }}
with:
tag_name: ${{ inputs.release-tag }}
files: app/build/outputs/apk/meta/release/*
generate_release_notes: true
- name: Release Changelog Builder
uses: mikepenz/release-changelog-builder-action@v4.1.1
with:
configurationJson: |
{
"ignore_labels": [
"Update"
],
}