Skip to content

Commit 1418739

Browse files
authored
Merge pull request #2 from s1204IT/setup-ci
Optimize build workflow
2 parents e282081 + 6179b3d commit 1418739

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
1-
name: CI
1+
name: Build
22

33
on:
44
push:
5-
branches: "*"
5+
paths-ignore:
6+
- "CONTRIB"
7+
- "LICENSE"
8+
- "PRIVACY"
9+
- "README.md"
610
pull_request:
711
branches: [ "master" ]
12+
workflow_dispatch:
813

914
jobs:
1015
build:
11-
16+
name: Build
1217
runs-on: ubuntu-latest
13-
1418
steps:
15-
- uses: actions/checkout@v4
16-
- name: Set up JDK 17
17-
uses: actions/setup-java@v3
19+
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Java
24+
uses: actions/setup-java@v4
1825
with:
1926
java-version: '17'
2027
distribution: 'temurin'
21-
- name: Install Bazel
22-
run: |
23-
sudo apt install apt-transport-https curl gnupg -y
24-
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg
25-
sudo mv bazel-archive-keyring.gpg /usr/share/keyrings
26-
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
27-
sudo apt update
28-
sudo apt install bazel -y
28+
29+
- name: Setup Bazel
30+
uses: bazel-contrib/[email protected]
31+
with:
32+
bazelisk-cache: true
33+
disk-cache: ${{ github.workflow }}
34+
repository-cache: true
35+
2936
- name: Build
3037
run: |
31-
chmod +X build.sh
38+
chmod +x build.sh
3239
./build.sh
40+
3341
- name: Test
34-
run: bazel test :all
42+
run: bazel test :all
43+
44+
- name: Set environments
45+
run: |
46+
{
47+
echo "commit=$(echo ${{ github.sha }} | cut -c-7)"
48+
echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})"
49+
echo "version=v$(grep -o 'android:versionName="[^"]*"' src/main/AndroidManifest.xml | awk -F'"' '{print $2}')"
50+
} >> $GITHUB_ENV
51+
52+
- name: Upload APK
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ env.repo }}-${{ env.version }}@${{ env.commit }}
56+
path: bazel-bin/*.apk

0 commit comments

Comments
 (0)