[Feat] Add linux build action #31
This file contains hidden or 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
name: Bazel CLI Build | |
on: | |
push: | |
paths-ignore: | |
- 'doc/**' | |
- 'example/**' | |
- '**/*.md' | |
tags: | |
- '*' | |
pull_request: | |
paths-ignore: | |
- 'doc/**' | |
- 'example/**' | |
- '**/*.md' | |
workflow_dispatch: | |
jobs: | |
build-linux: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install Software | |
run: | | |
sudo apt-get update && sudo apt-get install -y python3 nodejs clang-13 libclang-13-dev python3-pip build-essential | |
sudo python3 -m pip install pip==24.0 | |
sudo ln -sf /usr/bin/python3 /usr/bin/python | |
sudo ln -sf /usr/bin/clang-13 /usr/bin/clang | |
sudo ln -sf /usr/bin/clang++-13 /usr/bin/clang++ | |
- name: Set up Bazel | |
uses: bazel-contrib/[email protected] | |
with: | |
bazelisk-cache: true | |
disk-cache: ${{ github.workflow }} | |
repository-cache: true | |
- name: Build All | |
run: bazel build //... | |
- name: Rename artifact with tag for release | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
cp bazel-bin/sparrow-cli.tar.gz sparrow-cli-${TAG_NAME}-linux.tar.gz | |
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV | |
- name: Rename artifact with commit hash for push | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
run: | | |
SHORT_COMMIT=$(echo ${{ github.sha }} | cut -c1-7) | |
cp bazel-bin/sparrow-cli.tar.gz sparrow-cli-${SHORT_COMMIT}-linux.tar.gz | |
echo "ARTIFACT_NAME=sparrow-cli-${SHORT_COMMIT}-linux" >> $GITHUB_ENV | |
- name: Upload sparrow-cli.tar.gz artifact | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: sparrow-cli-*-linux.tar.gz | |
- name: Upload to Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: sparrow-cli-*-linux.tar.gz | |
build-macos: | |
runs-on: macos-14 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install python3 | |
run: brew install python3 | |
- name: Set up Bazel | |
uses: bazel-contrib/[email protected] | |
with: | |
bazelisk-cache: true | |
disk-cache: ${{ github.workflow }} | |
repository-cache: true | |
- name: Build All | |
run: bazel build //... | |
- name: Rename artifact with tag for release | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
cp bazel-bin/sparrow-cli.tar.gz sparrow-cli-${TAG_NAME}-mac.tar.gz | |
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV | |
- name: Rename artifact with commit hash for push | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
run: | | |
SHORT_COMMIT=$(echo ${{ github.sha }} | cut -c1-7) | |
cp bazel-bin/sparrow-cli.tar.gz sparrow-cli-${SHORT_COMMIT}-mac.tar.gz | |
echo "ARTIFACT_NAME=sparrow-cli-${SHORT_COMMIT}-mac" >> $GITHUB_ENV | |
- name: Upload sparrow-cli.tar.gz artifact | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: sparrow-cli-*-mac.tar.gz | |
- name: Upload to Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: sparrow-cli-*-mac.tar.gz |