-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (114 loc) · 3.86 KB
/
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
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
name: Build
on:
workflow_dispatch:
inputs:
useCache:
description: Use GHA cache
type: boolean
required: false
default: true
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
pre_commit:
name: Pre-commit checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
build_matrix:
needs: pre_commit
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- id: matrix
name: build matrix
shell: python
run: |
import os
import json
reduced = [
("x86_64", "ubuntu-24.04", ("manylinux2014", "manylinux_2_28", "manylinux_2_34", "musllinux_1_2")),
("aarch64", "ubuntu-24.04-arm", ("manylinux2014", "manylinux_2_28", "manylinux_2_34", "musllinux_1_2")),
("i686", "ubuntu-24.04", ("manylinux2014", "musllinux_1_2")),
("armv7l", "ubuntu-24.04-arm", ("musllinux_1_2",)),
]
expanded = [{"policy": policy, "platform": platform, "runner": runner} for platform, runner, policies in reduced for policy in policies]
print(json.dumps(expanded, indent=2))
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
f.write(f"matrix={json.dumps(expanded)}")
build_manylinux:
name: ${{ matrix.policy }}_${{ matrix.platform }}
needs: build_matrix
runs-on: ${{ matrix.runner }}
permissions:
actions: write # this permission is needed to delete cache
packages: write
contents: read
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.build_matrix.outputs.matrix) }}
env:
POLICY: ${{ matrix.policy }}
PLATFORM: ${{ matrix.platform }}
COMMIT_SHA: ${{ github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 50
submodules: true
- name: Patch
run: |
./patch.sh
echo "COMMIT_SHA=$(git rev-parse HEAD:manylinux)" >> $GITHUB_ENV
- name: Start Docker
run: |
sudo systemctl start docker
while ! docker info; do sleep 1; done
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Restore cache
if: github.event_name != 'workflow_dispatch' || fromJSON(github.event.inputs.useCache)
uses: actions/cache/restore@v4
with:
path: manylinux/.buildx-cache-${{ matrix.policy }}_${{ matrix.platform }}/*
key: buildx-cache-${{ matrix.policy }}-${{ matrix.platform }}
- name: Build
run: |
cd manylinux
./build.sh
- name: Delete cache
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
KEY="buildx-cache-${{ matrix.policy }}-${{ matrix.platform }}"
gh cache delete ${KEY} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save cache
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/cache/save@v4
with:
path: manylinux/.buildx-cache-${{ matrix.policy }}_${{ matrix.platform }}/*
key: buildx-cache-${{ matrix.policy }}-${{ matrix.platform }}
- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'karellen/karellen-manylinux'
run: |
cd manylinux
./deploy.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
all_passed:
needs: [build_manylinux]
runs-on: ubuntu-latest
steps:
- run: echo "All jobs passed"