forked from Aliucord/Aliucord
-
Notifications
You must be signed in to change notification settings - Fork 5
151 lines (131 loc) · 4.99 KB
/
build.yml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 8
# Prevent duplicate workflow run for PRs from same repo
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork }}
permissions:
contents: read
steps:
- name: Checkout src
uses: actions/checkout@v4
with:
path: src
persist-credentials: false
- name: Setup JDK 11
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "11"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 9862592 # 10.0 is the last version working with JDK 11
- name: Build project
run: |
cd $GITHUB_WORKSPACE/src
# Check if this should be marked as a release build
export RELEASE=${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
chmod +x gradlew
./gradlew --stacktrace :Aliucord:make :Injector:make :patches:package :patches:disassembleWithPatches :patches:test
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: |
${{ github.workspace }}/src/Aliucord/build/Aliucord.zip
${{ github.workspace }}/src/Injector/build/Injector.dex
${{ github.workspace }}/src/patches/build/patches.zip
deploy:
runs-on: ubuntu-24.04
timeout-minutes: 3
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs: [ build ]
permissions:
contents: write
steps:
- name: Checkout src
uses: actions/checkout@v4
with:
path: src
- name: Checkout builds
uses: actions/checkout@v4
with:
ref: builds
path: builds
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: artifacts
- name: Deploy builds
if: github.ref == 'refs/heads/main'
run: |
# Flatten downloaded artifacts
find $GITHUB_WORKSPACE/artifacts -type f -exec mv -t $GITHUB_WORKSPACE/artifacts '{}' +
# Legacy Installer support for now
cp $GITHUB_WORKSPACE/src/.assets/AndroidManifest.xml $GITHUB_WORKSPACE/builds
# Extract component versions
coreVersion=$(cat $GITHUB_WORKSPACE/src/Aliucord/build.gradle.kts | grep -E 'version = "' | cut -d \" -f 2)
patchesVersion=$(cat $GITHUB_WORKSPACE/src/patches/build.gradle.kts | grep -E 'version = "' | cut -d \" -f 2)
injectorVersion=$(cat $GITHUB_WORKSPACE/src/Injector/build.gradle.kts | grep -E 'version = "' | cut -d \" -f 2)
# Copy over builds if version changed
cd $GITHUB_WORKSPACE/builds
[ "$(jq -r '.coreVersion' data.json)" != "$coreVersion" ] && cp $GITHUB_WORKSPACE/artifacts/Aliucord.zip .
[ "$(jq -r '.injectorVersion' data.json)" != "$injectorVersion" ] && cp $GITHUB_WORKSPACE/artifacts/Injector.dex .
[ "$(jq -r '.patchesVersion' data.json)" != "$patchesVersion" ] && cp $GITHUB_WORKSPACE/artifacts/patches.zip .
# Write versions to data.json
# `aliucordHash` is kept to force old builds to update
jq '. + { coreVersion: $cv, injectorVersion: $iv, patchesVersion: $pv, aliucordHash: "0000000" }' \
--arg cv $coreVersion \
--arg iv $injectorVersion \
--arg pv $patchesVersion \
../src/.assets/data.json > data.json
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
if [[ `git status --porcelain` ]]; then
git commit -m "Build $GITHUB_SHA"
git push
fi
# Publish core to maven if not originating from a PR
maven:
runs-on: ubuntu-24.04
timeout-minutes: 5
if: github.event_name != 'pull_request'
needs: [ build ]
permissions:
contents: read
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
steps:
- name: Checkout src
if: ${{ env.MAVEN_USERNAME != '' }}
uses: actions/checkout@v4
with:
path: src
persist-credentials: false
- name: Setup JDK 11
if: ${{ env.MAVEN_USERNAME != '' }}
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "11"
- name: Build & Publish to Maven
if: ${{ env.MAVEN_USERNAME != '' }}
run: |
cd $GITHUB_WORKSPACE/src
chmod +x gradlew
./gradlew :Aliucord:publish --stacktrace -Pversion=$GITHUB_REF_NAME-SNAPSHOT
./gradlew :Aliucord:publish --stacktrace -Pversion=$(git rev-parse --short "$GITHUB_SHA") | exit 0
env:
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}