-
Notifications
You must be signed in to change notification settings - Fork 90
85 lines (81 loc) · 2.85 KB
/
action-build.yml
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
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
# this action will require write permission to id-token
name: Build shims
on:
workflow_call:
inputs:
os:
required: true
type: string
runtime:
required: true
type: string
target:
required: false
type: string
slug:
required: true
type: string
arch:
required: false
type: string
sign:
default: false
type: boolean
jobs:
build-sign-upload:
permissions:
id-token: write
name: build for ${{ inputs.slug }}
runs-on: ${{ inputs.os }}
steps:
- name: describe runner
run: |
echo "::notice::Running job with os: '${{ inputs.os }}', arch: '${{ inputs.arch }}', slug: '${{ inputs.slug }}', runtime: '${{ inputs.runtime }}', target: '${{ inputs.target }}'"
- uses: actions/checkout@v4
- name: Setup build env
run: |
os=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
./scripts/setup-$os.sh
shell: bash
- uses: actions-rust-lang/setup-rust-toolchain@v1
env:
RUST_CACHE_KEY_OS: rust-cache-${{ inputs.os }}-${{ inputs.slug }}
with:
rustflags: '' #Disable. By default this action sets environment variable is set to -D warnings. We manage this in the Makefile
- name: Setup cross-rs
if: runner.os == 'Linux'
run: ./scripts/setup-cross.sh ${{ inputs.target }}
- name: Setup build profile
shell: bash
run: echo "OPT_PROFILE=release" >> ${GITHUB_ENV}
- name: Build
run: make build-${{ inputs.runtime }}
- name: Run tests
timeout-minutes: 5
run: |
make test-${{ inputs.runtime }}
if: ${{ inputs.arch == 'x86_64' }}
- name: Sign the binary
if: ${{ inputs.runtime != 'common' && inputs.slug != 'windows' && inputs.sign }}
uses: ./.github/workflows/action-sign.yml
with:
runtime: ${{ inputs.runtime }}
os: ${{ inputs.os }}
- name: Package artifacts
if: ${{ inputs.runtime != 'common' }}
shell: bash
run: |
make dist-${{ inputs.runtime }}
# Check if there's any files to archive as tar fails otherwise
if stat dist/bin/* >/dev/null 2>&1; then
tar -czf dist/containerd-shim-${{ inputs.runtime }}-${{ inputs.slug }}.tar.gz -C dist/bin .
else
tar -czf dist/containerd-shim-${{ inputs.runtime }}-${{ inputs.slug }}.tar.gz -T /dev/null
fi
- name: Upload artifacts
if: ${{ inputs.runtime != 'common' }}
uses: actions/upload-artifact@master
with:
name: containerd-shim-${{ inputs.runtime }}-${{ inputs.slug }}
path: dist/containerd-shim-${{ inputs.runtime }}-${{ inputs.slug }}.tar.gz