Skip to content

Commit bccce36

Browse files
authored
Merge pull request #124 from codefuse-ai/add-linux-build-action
[Feat] Add linux build action
2 parents a406794 + 52fda8a commit bccce36

File tree

1 file changed

+74
-4
lines changed

1 file changed

+74
-4
lines changed

.github/workflows/bazel_cli_build.yml

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: Bazel CLI Build (macOS)
1+
name: Bazel CLI Build
22

33
on:
44
push:
55
paths-ignore:
66
- 'doc/**'
77
- 'example/**'
88
- '**/*.md'
9+
tags:
10+
- '*'
911
pull_request:
1012
paths-ignore:
1113
- 'doc/**'
@@ -15,8 +17,56 @@ on:
1517

1618

1719
jobs:
20+
build-linux:
21+
runs-on: ubuntu-22.04
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
submodules: true
27+
- name: Install Software
28+
run: |
29+
sudo apt-get update && sudo apt-get install -y python3 nodejs clang-13 libclang-13-dev python3-pip build-essential
30+
sudo python3 -m pip install pip==24.0
31+
sudo ln -sf /usr/bin/python3 /usr/bin/python
32+
sudo ln -sf /usr/bin/clang-13 /usr/bin/clang
33+
sudo ln -sf /usr/bin/clang++-13 /usr/bin/clang++
34+
- name: Set up Bazel
35+
uses: bazel-contrib/setup-bazel@0.14.0
36+
with:
37+
bazelisk-cache: true
38+
disk-cache: ${{ github.workflow }}
39+
repository-cache: true
40+
- name: Build All
41+
run: bazel build //...
42+
- name: Prepare artifact name and copy
43+
run: |
44+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
45+
TAG_NAME="${GITHUB_REF#refs/tags/}"
46+
ARTIFACT_NAME="sparrow-cli-${TAG_NAME}-linux"
47+
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
48+
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
49+
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
50+
else
51+
SHORT_COMMIT="$(echo ${{ github.sha }} | cut -c1-7)"
52+
ARTIFACT_NAME="sparrow-cli-${SHORT_COMMIT}-linux"
53+
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
54+
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
55+
fi
56+
- name: Upload sparrow-cli.tar.gz artifact
57+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: ${{ env.ARTIFACT_NAME }}.tar.gz
61+
path: ${{ env.ARTIFACT_NAME }}.tar.gz
62+
- name: Upload to Release
63+
if: startsWith(github.ref, 'refs/tags/')
64+
uses: softprops/action-gh-release@v1
65+
with:
66+
files: ${{ env.ARTIFACT_NAME }}.tar.gz
67+
1868
build-macos:
19-
runs-on: macos-latest
69+
runs-on: macos-14
2070
steps:
2171
- name: Checkout repository
2272
uses: actions/checkout@v4
@@ -32,8 +82,28 @@ jobs:
3282
repository-cache: true
3383
- name: Build All
3484
run: bazel build //...
85+
- name: Prepare artifact name and copy
86+
run: |
87+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
88+
TAG_NAME="${GITHUB_REF#refs/tags/}"
89+
ARTIFACT_NAME="sparrow-cli-${TAG_NAME}-mac"
90+
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
91+
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
92+
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
93+
else
94+
SHORT_COMMIT="$(echo ${{ github.sha }} | cut -c1-7)"
95+
ARTIFACT_NAME="sparrow-cli-${SHORT_COMMIT}-mac"
96+
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
97+
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
98+
fi
3599
- name: Upload sparrow-cli.tar.gz artifact
100+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
36101
uses: actions/upload-artifact@v4
37102
with:
38-
name: sparrow-cli
39-
path: bazel-bin/sparrow-cli.tar.gz
103+
name: ${{ env.ARTIFACT_NAME }}.tar.gz
104+
path: ${{ env.ARTIFACT_NAME }}.tar.gz
105+
- name: Upload to Release
106+
if: startsWith(github.ref, 'refs/tags/')
107+
uses: softprops/action-gh-release@v1
108+
with:
109+
files: ${{ env.ARTIFACT_NAME }}.tar.gz

0 commit comments

Comments
 (0)