-
Notifications
You must be signed in to change notification settings - Fork 26
103 lines (91 loc) · 3.17 KB
/
ci.yml
File metadata and controls
103 lines (91 loc) · 3.17 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
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: CI
on:
push:
branches: [ "main" ]
tags:
- v[0-9]+.[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+
pull_request:
branches: [ "main" ]
env:
GO_VERSION: "1.22.5"
jobs:
build-vnpu:
runs-on: ubuntu-22.04-arm
container:
image: ghcr.io/dsfans2014/ascend-device-plugin/ascend-lib:0.2
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release
working-directory: ./libvnpu
- name: Prepare artifacts for upload
run: |
mkdir -p ./artifacts
cp libvnpu/target/release/limiter ./artifacts/
cp libvnpu/target/release/libvnpu.so ./artifacts/
echo "/hami-vnpu-core/libvnpu.so" > ./artifacts/ld.so.preload
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
if-no-files-found: error
path: ./artifacts/*
build:
env:
IMAGE_NAME: ${{ secrets.IMAGE_NAME || 'projecthami/ascend-device-plugin' }}
runs-on: ubuntu-latest
needs: ["build-vnpu"]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: true
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./lib/hami-vnpu-core/
- name: Docker Login
if: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') }}
uses: docker/login-action@v3.6.0
with:
username: ${{ secrets.DOCKERHUB_TOKEN }}
password: ${{ secrets.DOCKERHUB_PASSWD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract tag name
id: tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
echo "VERSION=${TAG_NAME#v}" >> $GITHUB_OUTPUT
echo "Extracted version: ${VERSION}"
else
echo "VERSION=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') }}
build-args: |
BASE_IMAGE=ubuntu:20.04
GO_VERSION=${{ env.GO_VERSION }}
VERSION=${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}-${{ github.sha }}
tags: ${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.VERSION }}