-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (153 loc) · 5.35 KB
/
build_artifacts.yaml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: build_artifacts
on:
workflow_dispatch:
schedule:
- cron: '*/5 * * * *'
jobs:
version_check:
runs-on: ubuntu-latest
outputs:
opendal_core_version: ${{ steps.set-version.outputs.opendal_core_version }}
opendal_go_version: ${{ steps.set-version.outputs.opendal_go_version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install Dependencies
run: npm install semver
- uses: actions/github-script@v7
id: set-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const script = require('.github/scripts/setup_version.js')
await script({github})
matrix:
needs: [ version_check ]
runs-on: ubuntu-latest
if: ${{ needs.version_check.outputs.opendal_go_version != '' }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
name: Setup Matrix
run: |
MATRIX=$(yq -o=json -I=0 "." .github/scripts/matrix.yaml | sed 's/ //g')
echo "Matrix:"
echo "$MATRIX" | jq .
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
build:
needs: [ version_check, matrix ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
repository: "apache/opendal"
ref: ${{ needs.version_check.outputs.opendal_core_version }}
- uses: actions/checkout@v4
with:
path: "tools"
- name: Setup Rust toolchain
uses: ./.github/actions/setup
- name: Setup Target
env:
TARGET: ${{ matrix.build.target }}
run: rustup target add $TARGET
- name: Setup AArch64 Tool
working-directory: bindings/c
if: ${{ matrix.build.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu -y
mkdir .cargo
cat << EOF > .cargo/config.toml
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup Service
env:
OPENDAL_FEATURES: "layers-blocking,services-${{ matrix.service }}"
run: |
python -m pip install toml
python tools/.github/scripts/setup_features.py
- name: Build ${{ matrix.service }} ${{ matrix.build.target }}
working-directory: bindings/c
env:
SERVICE: ${{ matrix.service }}
TARGET: ${{ matrix.build.target }}
CC: ${{ matrix.build.cc }}
run: |
cargo build --target $TARGET --release
sudo apt install zstd
zstd -22 ./target/$TARGET/release/libopendal_c.so -o ./libopendal_c.$TARGET.so.zst
- uses: actions/upload-artifact@v4
with:
name: "libopendal_c_${{ needs.version_check.outputs.opendal_core_version }}_${{ matrix.service }}_${{ matrix.build.target }}"
if-no-files-found: "error"
path: "bindings/c/libopendal_c.${{ matrix.build.target }}.so.zst"
overwrite: "true"
generate:
needs: [ version_check, matrix, build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/download-artifact@v4
- name: Generate Template
env:
MATRIX: ${{ needs.matrix.outputs.matrix }}
VERSION: ${{ needs.version_check.outputs.opendal_core_version }}
working-directory: internal/generate
run: |
go run generate.go
- name: Auto Commit
env:
VERSION: ${{ needs.version_check.outputs.opendal_core_version }}
TAG: ${{ needs.version_check.outputs.opendal_go_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "Github Actions"
git config --global user.email "[email protected]"
git add -A
git commit --allow-empty -m "Auto commit by GitHub Actions $VERSION"
git push -f --set-upstream origin main
- name: Auto Tag
if: ${{ needs.version_check.outputs.opendal_go_version != '' }}
env:
TAG: ${{ needs.version_check.outputs.opendal_go_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# The tag is used for version_check only.
git tag $TAG
git push -f origin $TAG
tag:
needs: [ version_check, matrix, build, generate ]
runs-on: ubuntu-latest
if: ${{ needs.version_check.outputs.opendal_go_version != '' }}
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.matrix.outputs.matrix).service }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.version_check.outputs.opendal_go_version }}
- name: Auto Service Tag
env:
SERVICE: ${{ matrix.service }}
VERSION: ${{ needs.version_check.outputs.opendal_go_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SERVICE=$(echo $SERVICE | tr '-' '_')
TAG="$SERVICE/$VERSION"
git tag $TAG
git push -f origin $TAG