Skip to content

Commit d45ad99

Browse files
andifejustinchuby
andauthored
Combine different release pipelines by the use of reusable workflows (onnx#6277)
### Description <!-- - Describe your changes. --> This pull request should be the start of a pipeline (current status of the considerations under onnx#6246) that automatically generates a whls after tagging, signs it and publishes it directly to Pypi to improve supply chain security. As this is all too much at once, the changes will be introduced and tested gradually. Changes related to this PR: Reusable Workflows are used to merge the individual OS release builds together (we need one process as we want to have all artifacts in one pipeline, so there is not need to download them manuelly). The workflows are currently not really "reusable", as we more or less use pypi creditionals in the workflow, among other things. I reused our testpypi weekly repo as I didn't want to change our behavoir for pypi and testpypi. Maybe it would make sense to adapt the process right away so that you can trigger our "Weekly" manually via the Github interface for testing and don't have to wait a week ;-) #### Key points for the review: * How do we want to configure concurrency * What concurrency-groups do we need? * Where do we need "cancel-in-progress"? #### Not part of the pull request: * Extract publish whl to pypi/testpyp * Introduce trusted publishing * ... ### Motivation and Context * see onnx#6246 --------- Signed-off-by: Andreas Fehlner <[email protected]> Co-authored-by: Justin Chu <[email protected]>
1 parent 2c4b0cd commit d45ad99

File tree

5 files changed

+127
-67
lines changed

5 files changed

+127
-67
lines changed

.github/workflows/create_release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright (c) ONNX Project Contributors
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Create Releases
6+
on:
7+
schedule:
8+
# Run weekly on Monday 00:00
9+
- cron: '00 00 * * MON'
10+
push:
11+
branches: [main, rel-*]
12+
pull_request:
13+
branches: [main, rel-*]
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
22+
call-workflow-ubuntu_x86:
23+
strategy:
24+
matrix:
25+
os: ['ubuntu-latest']
26+
uses: ./.github/workflows/release_linux_x86_64.yml
27+
with:
28+
os: "linux_x86_64"
29+
30+
call-workflow-ubuntu_aarch64:
31+
strategy:
32+
matrix:
33+
os: ['ubuntu-latest']
34+
uses: ./.github/workflows/release_linux_aarch64.yml
35+
with:
36+
os: "linux_aarch64"
37+
38+
call-workflow-win:
39+
strategy:
40+
matrix:
41+
os: ['windows-latest']
42+
uses: ./.github/workflows/release_win.yml
43+
with:
44+
os: "win"
45+
46+
call-workflow-mac:
47+
strategy:
48+
matrix:
49+
os: ['mac-latest']
50+
uses: ./.github/workflows/release_mac.yml
51+
with:
52+
os: "macos"
53+
54+
55+
56+
publish_to_testpypi:
57+
# TODO Add a deployment step for reviewing https://docs.github.com/en/actions/managing-workflow-runs/reviewing-deployments
58+
name: Release (Publish to testpypi, onnxweekly)
59+
runs-on: ubuntu-latest
60+
needs: [call-workflow-ubuntu_x86, call-workflow-ubuntu_aarch64, call-workflow-mac, call-workflow-win]
61+
if: (github.ref == 'refs/head/main') && (github.event_name != 'pull_request') && ((needs.call-workflow-mac.result == 'success') || (needs.call-workflow-ubuntu_x86.result == 'success') || (needs.call-workflow-ubuntu_aarch64.result == 'success') || (needs.call-workflow-win.result == 'success'))
62+
63+
environment:
64+
name: testpypi
65+
url: https://test.pypi.org/p/onnx
66+
67+
permissions:
68+
contents: write # IMPORTANT: mandatory for making GitHub Releases
69+
id-token: write # IMPORTANT: mandatory for sigstore
70+
71+
steps:
72+
73+
- uses: actions/download-artifact@v4
74+
with:
75+
pattern: wheels*
76+
path: dist
77+
merge-multiple: true
78+
79+
- name: Publish distribution to TestPyPI
80+
if: (github.event_name == 'schedule') && (github.repository_owner == 'onnx')
81+
uses: pypa/gh-action-pypi-publish@release/v1
82+
with:
83+
repository-url: https://test.pypi.org/legacy/
84+
verbose: true
85+
print-hash: true
86+

.github/workflows/release_linux_aarch64.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44

55
name: LinuxRelease_aarch64
66

7-
on:
8-
schedule:
9-
# Run weekly on Monday 00:00
10-
- cron: '00 00 * * MON'
11-
push:
12-
branches: [main, rel-*]
13-
pull_request:
14-
branches: [main, rel-*]
15-
workflow_dispatch:
7+
on: # Specifies the event triggering the workflow
8+
workflow_call: # Indicates that this is a reusable workflow
9+
inputs:
10+
os:
11+
required: true
12+
type: string
1613

1714
permissions: # set top-level default permissions as security best practice
1815
contents: read
1916

20-
concurrency:
21-
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
22-
cancel-in-progress: true
23-
2417
jobs:
2518
build:
2619
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
@@ -83,11 +76,12 @@ jobs:
8376
pytest && \
8477
deactivate'
8578
86-
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
79+
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
8780
with:
88-
name: wheels
89-
path: dist
90-
81+
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
82+
path: |
83+
./dist/*.whl
84+
9185
- name: Upload wheel to PyPI weekly
9286
if: (github.event_name == 'schedule') # Only triggered by weekly event
9387
run: |

.github/workflows/release_linux_x86_64.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44

55
name: LinuxRelease_x86_64
66

7-
on:
8-
schedule:
9-
# Run weekly on Monday 00:00
10-
- cron: '00 00 * * MON'
11-
push:
12-
branches: [main, rel-*]
13-
pull_request:
14-
branches: [main, rel-*]
15-
workflow_dispatch:
7+
on: # Specifies the event triggering the workflow
8+
workflow_call: # Indicates that this is a reusable workflow
9+
inputs:
10+
os:
11+
required: true
12+
type: string
1613

1714
permissions: # set top-level default permissions as security best practice
1815
contents: read
1916

20-
concurrency:
21-
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
22-
cancel-in-progress: true
23-
2417
jobs:
2518
build:
2619
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
@@ -65,10 +58,12 @@ jobs:
6558
python -m pip install dist/*manylinux2014_x86_64.whl
6659
pytest
6760
68-
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
61+
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
6962
with:
70-
name: wheels
71-
path: dist
63+
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
64+
path: |
65+
./dist/*.whl
66+
7267
7368
- name: Upload wheel to PyPI weekly
7469
if: (github.event_name == 'schedule') # Only triggered by weekly event

.github/workflows/release_mac.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44

55
name: MacRelease
66

7-
on:
8-
schedule:
9-
# Run weekly on Monday 00:00
10-
- cron: '00 00 * * MON'
11-
push:
12-
branches: [main, rel-*]
13-
pull_request:
14-
branches: [main, rel-*]
15-
workflow_dispatch:
7+
on: # Specifies the event triggering the workflow
8+
workflow_call: # Indicates that this is a reusable workflow
9+
inputs:
10+
os:
11+
required: true
12+
type: string
1613

1714
# Use MACOSX_DEPLOYMENT_TARGET=12.0 to produce compatible wheel
1815
env:
@@ -21,10 +18,6 @@ env:
2118
permissions:
2219
contents: read
2320

24-
concurrency:
25-
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
26-
cancel-in-progress: true
27-
2821
jobs:
2922
build:
3023
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
@@ -68,10 +61,10 @@ jobs:
6861
fi
6962
python -m build --wheel
7063
71-
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
64+
- uses: actions/upload-artifact@v4
7265
with:
73-
name: macos-wheel-${{ matrix.python-version }}
74-
path: dist
66+
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
67+
path: dist/*.whl
7568

7669
test:
7770
needs: build
@@ -93,9 +86,9 @@ jobs:
9386
arch -${{ matrix.target-architecture }} python -m pip install -q --upgrade pip
9487
arch -${{ matrix.target-architecture }} python -m pip install -q -r requirements-release.txt
9588
96-
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
89+
- uses: actions/download-artifact@v4
9790
with:
98-
name: macos-wheel-${{ matrix.python-version }}
91+
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
9992
path: dist
10093

10194
- name: Test the wheel

.github/workflows/release_win.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44

55
name: WindowsRelease
66

7-
on:
8-
schedule:
9-
# Run weekly on Monday 00:00
10-
- cron: '00 00 * * MON'
11-
push:
12-
branches: [main, rel-*]
13-
pull_request:
14-
branches: [main, rel-*]
15-
workflow_dispatch:
7+
on: # Specifies the event triggering the workflow
8+
workflow_call: # Indicates that this is a reusable workflow
9+
inputs:
10+
os:
11+
required: true
12+
type: string
1613

1714
permissions: # set top-level default permissions as security best practice
1815
contents: read
1916

20-
concurrency:
21-
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
22-
cancel-in-progress: true
23-
2417
jobs:
2518
build:
2619
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
@@ -79,15 +72,14 @@ jobs:
7972
}
8073
python -m build --wheel
8174
Get-ChildItem -Path dist/*.whl | foreach {python -m pip install --upgrade $_.fullname}
82-
8375
- name: Test the installed wheel
8476
run: |
8577
cd onnx
8678
pytest
8779
88-
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
80+
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b
8981
with:
90-
name: wheels
82+
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}-${{matrix.architecture}}
9183
path: ./onnx/dist
9284

9385
- name: Upload onnx-weekly wheel to PyPI/PyPI weekly

0 commit comments

Comments
 (0)