Skip to content

Commit

Permalink
Merge pull request googlesamples#2 from s1204IT/setup-ci
Browse files Browse the repository at this point in the history
Optimize build workflow
  • Loading branch information
SM2A authored May 28, 2024
2 parents e282081 + 6179b3d commit 1418739
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions .github/workflows/build.yml
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

0 comments on commit 1418739

Please sign in to comment.