forked from googlesamples/android-testdpc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request googlesamples#2 from s1204IT/setup-ci
Optimize build workflow
- Loading branch information
Showing
1 changed file
with
39 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,56 @@ | ||
name: CI | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
paths-ignore: | ||
- "CONTRIB" | ||
- "LICENSE" | ||
- "PRIVACY" | ||
- "README.md" | ||
pull_request: | ||
branches: [ "master" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
- name: Install Bazel | ||
run: | | ||
sudo apt install apt-transport-https curl gnupg -y | ||
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg | ||
sudo mv bazel-archive-keyring.gpg /usr/share/keyrings | ||
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 | ||
sudo apt update | ||
sudo apt install bazel -y | ||
|
||
- name: Setup Bazel | ||
uses: bazel-contrib/setup-bazel@0.8.4 | ||
with: | ||
bazelisk-cache: true | ||
disk-cache: ${{ github.workflow }} | ||
repository-cache: true | ||
|
||
- name: Build | ||
run: | | ||
chmod +X build.sh | ||
chmod +x build.sh | ||
./build.sh | ||
- name: Test | ||
run: bazel test :all | ||
run: bazel test :all | ||
|
||
- name: Set environments | ||
run: | | ||
{ | ||
echo "commit=$(echo ${{ github.sha }} | cut -c-7)" | ||
echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})" | ||
echo "version=v$(grep -o 'android:versionName="[^"]*"' src/main/AndroidManifest.xml | awk -F'"' '{print $2}')" | ||
} >> $GITHUB_ENV | ||
- name: Upload APK | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.repo }}-${{ env.version }}@${{ env.commit }} | ||
path: bazel-bin/*.apk |