build_artifacts #17261
This file contains 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: 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 "actions@github.com" | |
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 |