Skip to content

Commit 251169f

Browse files
committed
fix: Introduce reusable workflow
1 parent 737d418 commit 251169f

File tree

2 files changed

+67
-108
lines changed

2 files changed

+67
-108
lines changed

.github/workflows/build-wheel.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build Wheel
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
required: true
8+
type: string
9+
architecture:
10+
required: false
11+
type: string
12+
artifact-name:
13+
required: true
14+
type: string
15+
secrets:
16+
github-token:
17+
required: true
18+
19+
jobs:
20+
build:
21+
runs-on: ${{ inputs.runs-on }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ inputs.python-version }}
27+
architecture: ${{ inputs.architecture }}
28+
cache: "pip"
29+
- name: Install dependencies
30+
run: pip install -r requirements.txt
31+
- name: Prepare build directories
32+
run: |
33+
mkdir -p artifacts
34+
mkdir -p src/c2pa/libs
35+
rm -rf dist/* build/*
36+
- name: Download native artifacts (from tag c2pa-v0.55.0)
37+
run: python3 scripts/download_artifacts.py c2pa-v0.55.0
38+
- name: Build wheel
39+
run: python setup.py bdist_wheel
40+
- name: Upload wheels
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: ${{ inputs.artifact-name }}
44+
path: dist

.github/workflows/build.yml

Lines changed: 23 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -55,145 +55,60 @@ jobs:
5555
# - run: pytest
5656

5757
linux:
58-
runs-on: ubuntu-latest
59-
58+
uses: ./.github/workflows/build-wheel.yml
59+
with:
60+
python-version: "3.10"
61+
artifact-name: wheels-${{ matrix.target }}
62+
strategy:
63+
matrix:
64+
target: [x86_64, aarch64]
6065
if: |
6166
github.event_name != 'pull_request' ||
6267
github.event.pull_request.author_association == 'COLLABORATOR' ||
6368
github.event.pull_request.author_association == 'MEMBER' ||
6469
github.event.pull_request.user.login == 'dependabot[bot]' ||
6570
contains(github.event.pull_request.labels.*.name, 'safe to test')
6671
72+
windows:
73+
uses: ./.github/workflows/build-wheel.yml
74+
with:
75+
python-version: "3.10"
76+
architecture: ${{ matrix.target }}
77+
artifact-name: wheels-${{ matrix.target }}
6778
strategy:
6879
matrix:
69-
target: [x86_64, aarch64]
70-
steps:
71-
- uses: actions/checkout@v4
72-
- uses: actions/setup-python@v5
73-
with:
74-
python-version: "3.10"
75-
cache: "pip"
76-
- name: Install dependencies
77-
run: pip install -r requirements.txt
78-
- name: Prepare build directories
79-
run: |
80-
mkdir -p artifacts
81-
mkdir -p src/c2pa/libs
82-
rm -rf dist/* build/*
83-
- name: Download native artifacts (from tag c2pa-v0.55.0)
84-
run: python3 scripts/download_artifacts.py c2pa-v0.55.0
85-
- name: Build wheel for ${{ matrix.target }}
86-
run: python setup.py bdist_wheel
87-
88-
- name: Upload wheels
89-
uses: actions/upload-artifact@v4
90-
with:
91-
name: wheels-${{ matrix.target }}
92-
path: dist
93-
94-
windows:
95-
runs-on: windows-latest
96-
80+
target: [x64, x86]
9781
if: |
9882
github.event_name != 'pull_request' ||
9983
github.event.pull_request.author_association == 'COLLABORATOR' ||
10084
github.event.pull_request.author_association == 'MEMBER' ||
10185
github.event.pull_request.user.login == 'dependabot[bot]' ||
10286
contains(github.event.pull_request.labels.*.name, 'safe to test')
10387
104-
strategy:
105-
matrix:
106-
target: [x64, x86]
107-
steps:
108-
- uses: actions/checkout@v4
109-
- uses: actions/setup-python@v5
110-
with:
111-
python-version: '3.10'
112-
architecture: ${{ matrix.target }}
113-
cache: "pip"
114-
- name: Install dependencies
115-
run: pip install -r requirements.txt
116-
- name: Prepare build directories
117-
run: |
118-
mkdir -p artifacts
119-
mkdir -p src/c2pa/libs
120-
rm -rf dist/* build/*
121-
- name: Download native artifacts (from tag c2pa-v0.55.0)
122-
run: python3 scripts/download_artifacts.py c2pa-v0.55.0
123-
- name: Build wheel
124-
run: python setup.py bdist_wheel
125-
- name: Upload wheels
126-
uses: actions/upload-artifact@v4
127-
with:
128-
name: wheels-${{ matrix.target }}
129-
path: dist
130-
13188
macos_x86:
132-
runs-on: macos-latest
133-
89+
uses: ./.github/workflows/build-wheel.yml
90+
with:
91+
python-version: "3.10"
92+
artifact-name: wheels-mac-x86_64
13493
if: |
13594
github.event_name != 'pull_request' ||
13695
github.event.pull_request.author_association == 'COLLABORATOR' ||
13796
github.event.pull_request.author_association == 'MEMBER' ||
13897
github.event.pull_request.user.login == 'dependabot[bot]' ||
13998
contains(github.event.pull_request.labels.*.name, 'safe to test')
14099
141-
steps:
142-
- uses: actions/checkout@v4
143-
- uses: actions/setup-python@v5
144-
with:
145-
python-version: '3.10'
146-
cache: "pip"
147-
- name: Install dependencies
148-
run: pip install -r requirements.txt
149-
- name: Prepare build directories
150-
run: |
151-
mkdir -p artifacts
152-
mkdir -p src/c2pa/libs
153-
rm -rf dist/* build/*
154-
- name: Download native artifacts (from tag c2pa-v0.55.0)
155-
run: python3 scripts/download_artifacts.py c2pa-v0.55.0
156-
- name: Build wheel
157-
run: python setup.py bdist_wheel
158-
- name: Upload wheels
159-
uses: actions/upload-artifact@v4
160-
with:
161-
name: wheels-mac-x86_64
162-
path: dist
163-
164100
macos_aarch64:
165-
runs-on: macos-latest-large
166-
101+
uses: ./.github/workflows/build-wheel.yml
102+
with:
103+
python-version: "3.10"
104+
artifact-name: wheels-mac-aarch64
167105
if: |
168106
github.event_name != 'pull_request' ||
169107
github.event.pull_request.author_association == 'COLLABORATOR' ||
170108
github.event.pull_request.author_association == 'MEMBER' ||
171109
github.event.pull_request.user.login == 'dependabot[bot]' ||
172110
contains(github.event.pull_request.labels.*.name, 'safe to test')
173111
174-
steps:
175-
- uses: actions/checkout@v4
176-
- uses: actions/setup-python@v5
177-
with:
178-
python-version: '3.10'
179-
cache: "pip"
180-
- name: Install dependencies
181-
run: pip install -r requirements.txt
182-
- name: Prepare build directories
183-
run: |
184-
mkdir -p artifacts
185-
mkdir -p src/c2pa/libs
186-
rm -rf dist/* build/*
187-
- name: Download native artifacts (from tag c2pa-v0.55.0)
188-
run: python3 scripts/download_artifacts.py c2pa-v0.55.0
189-
- name: Build wheel
190-
run: python setup.py bdist_wheel
191-
- name: Upload wheels
192-
uses: actions/upload-artifact@v4
193-
with:
194-
name: wheels-mac-aarch64
195-
path: dist
196-
197112
sdist:
198113
runs-on: ubuntu-latest
199114

@@ -225,7 +140,7 @@ jobs:
225140
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true'
226141
runs-on: ubuntu-latest
227142
environment: pypipublish
228-
needs: [linux, sdist]
143+
needs: [linux, windows, macos_x86, macos_aarch64, sdist]
229144
permissions:
230145
id-token: write
231146
contents: read

0 commit comments

Comments
 (0)