-
Notifications
You must be signed in to change notification settings - Fork 36
109 lines (105 loc) · 3.73 KB
/
bazel_cli_build.yml
File metadata and controls
109 lines (105 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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/setup-bazel@0.14.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build All
run: bazel build //...
- name: Prepare artifact name and copy
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
ARTIFACT_NAME="sparrow-cli-${TAG_NAME}-linux"
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
else
SHORT_COMMIT="$(echo ${{ github.sha }} | cut -c1-7)"
ARTIFACT_NAME="sparrow-cli-${SHORT_COMMIT}-linux"
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
fi
- name: Upload sparrow-cli.tar.gz artifact
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}.tar.gz
path: ${{ env.ARTIFACT_NAME }}.tar.gz
- name: Upload to Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ARTIFACT_NAME }}.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/setup-bazel@0.14.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build All
run: bazel build //...
- name: Prepare artifact name and copy
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
ARTIFACT_NAME="sparrow-cli-${TAG_NAME}-mac"
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
else
SHORT_COMMIT="$(echo ${{ github.sha }} | cut -c1-7)"
ARTIFACT_NAME="sparrow-cli-${SHORT_COMMIT}-mac"
cp bazel-bin/sparrow-cli.tar.gz "${ARTIFACT_NAME}.tar.gz"
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
fi
- name: Upload sparrow-cli.tar.gz artifact
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}.tar.gz
path: ${{ env.ARTIFACT_NAME }}.tar.gz
- name: Upload to Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ARTIFACT_NAME }}.tar.gz