Skip to content

Create Releases

Create Releases #29

# Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
name: Create Releases
on:
schedule:
# Run weekly on Monday 00:00 UTC
- cron: '00 00 * * MON'
push:
branches: [main, rel-*]
pull_request:
branches: [main, rel-*]
types:
- labeled # Trigger when a label is added to a PR, more information: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
workflow_dispatch:
inputs:
publish_pypi_weekly:
description: 'Publish to pypi-weekly'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
publish_testpypi_weekly:
description: 'Publish to testpypi-weekly'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
publish_testpypi_release:
description: 'Publish to testpypi-release'
required: true
type: choice
options:
- 'yes'
- 'no'
default: 'no'
build_mode:
description: 'Specify the build mode (release or preview)'
required: true
type: choice
options:
- 'release'
- 'preview'
default: 'preview'
permissions: # set top-level default permissions as security best practice
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true
jobs:
call-workflow-ubuntu_x86:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_linux_x86_64.yml
with:
os: "linux_x86_64"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-workflow-ubuntu_aarch64:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_linux_aarch64.yml
with:
os: "linux_aarch64"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-workflow-win:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_win_x86_64.yml
with:
os: "win"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-workflow-win-freethreading: # experimental
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_win_freethreading.yml
with:
os: "win"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-workflow-mac:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_mac.yml
with:
os: "macos"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
call-workflow-sdist:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/release_sdist.yml
with:
os: "macos"
build_mode: ${{ github.event.inputs.build_mode || 'preview' }}
check_for_publish_preview_build_to_testpypi_weekly:
name: Check for Publish preview build to test.pypi-weekly
runs-on: ubuntu-latest
needs: [call-workflow-ubuntu_x86, call-workflow-ubuntu_aarch64, call-workflow-mac, call-workflow-win, call-workflow-win-freethreading, call-workflow-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event.inputs.publish_testpypi_weekly == 'yes' ) && (github.ref == 'refs/heads/main') && (github.repository_owner == 'onnx') && (github.event_name == 'workflow_dispatch')
steps:
- name: print debug vars
run: |
echo "All environment variables:"
printenv
publish_preview_build_to_testpypi_weekly:
name: Publish preview build to test.pypi-weekly
runs-on: ubuntu-latest
needs: [check_for_publish_preview_build_to_testpypi_weekly]
environment:
name: testpypi-weekly
url: https://test.pypi.org/p/onnx-weekly
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write
steps:
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Publish preview build to test.pypi
if: (github.ref == 'refs/heads/main') && (github.event.inputs.publish_testpypi_weekly == 'yes') && (github.repository_owner == 'onnx')
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
print-hash: true
check_for_publish_release_build_to_testpypi:
name: Check for Publish release build to test.pypi
runs-on: ubuntu-latest
needs: [call-workflow-ubuntu_x86, call-workflow-ubuntu_aarch64, call-workflow-mac, call-workflow-win, call-workflow-win-freethreading, call-workflow-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event.inputs.publish_testpypi_release == 'yes' ) && startsWith(github.ref, 'refs/heads/rel') && (github.repository_owner == 'onnx') && (github.event_name == 'workflow_dispatch')
steps:
- name: print debug vars
run: |
echo "All environment variables:"
printenv
publish_release_build_to_testpypi:
name: Publish release build to test.pypi
runs-on: ubuntu-latest
needs: [check_for_publish_release_build_to_testpypi]
environment:
name: testpypi-release
url: https://test.pypi.org/p/onnx
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write
steps:
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806
if: (github.event_name == 'workflow_dispatch' )
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Publish release build to test.pypi
if: (startsWith(github.ref, 'refs/heads/rel')) && (github.event.inputs.publish_testpypi_release == 'yes') && (github.repository_owner == 'onnx')
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
print-hash: true
check_for_publish_preview_build_to_pypi_weekly:
name: Check for Publish preview build to pypi-weekly
runs-on: ubuntu-latest
needs: [call-workflow-ubuntu_x86, call-workflow-ubuntu_aarch64, call-workflow-mac, call-workflow-win, call-workflow-win-freethreading, call-workflow-sdist]
if: (!contains(join(needs.*.result, ' '), 'skipped')) && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
steps:
- name: placeholder for debug vars
run: |
echo "All environment variables:"
printenv
publish_preview_build_to_pypi_weekly:
name: Publish preview build to pypi-weekly
runs-on: ubuntu-latest
needs: [check_for_publish_preview_build_to_pypi_weekly]
environment:
name: pypi-weekly
url: https://pypi.org/p/onnx-weekly
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write
steps:
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
with:
pattern: wheels*
path: dist
merge-multiple: true
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
with:
pattern: sdist
path: dist
merge-multiple: true
- name: Publish preview_build to pypi-weekly
if: (github.ref == 'refs/heads/main') && (github.event_name == 'schedule' || github.event.inputs.publish_pypi_weekly == 'yes') && (github.repository_owner == 'onnx')
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
repository-url: https://upload.pypi.org/legacy/
verbose: true
print-hash: true
test_source_dist:
name: test source distribution
needs: [publish_preview_build_to_pypi_weekly]
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run release CIs')
uses: ./.github/workflows/preview_source_dist_test.yml
with:
os: "macos"