Skip to content

Commit

Permalink
Move release pipeline to a separate file | chore(release) (#619)
Browse files Browse the repository at this point in the history
I moved the release pipeline out because the tests are sometimes flaky
but we may not want them to block the scheduled release. I separated the
dev and official releases to use different environments so the official
releases can be manually reviewed before uploading to pypi.

Updated requirements-dev.txt
  • Loading branch information
justinchuby authored Apr 11, 2023
1 parent 5eafe2a commit ba0ff2e
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 57 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,55 +97,3 @@ jobs:
run: pip install .
- name: Build documentation
run: python -m sphinx docs dist/html

release:
needs: [test]
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- name: Checkout ONNX Script
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python build dependencies
run: |
python -m pip install --upgrade pip build wheel
- name: Build ONNX Script wheel dev version
run: |
python -m build
if: (!startsWith(github.ref, 'refs/tags/v'))
- name: Build ONNX Script wheel release version
run: |
python -m build
if: startsWith(github.ref, 'refs/tags/v')
env:
ONNX_SCRIPT_RELEASE: 1
- uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
- name: Install ONNX Script wheel
run: |
python -m pip install dist/*.whl
publish:
needs: [release]
runs-on: ubuntu-latest
environment: production
# Publish only when it is a scheduled run (weekly dev builds) or a tag push with version number
if: (github.event_name == 'schedule') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
# TODO: Check the tag name matches the VERSION file
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
107 changes: 107 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Release

on:
schedule:
# Run weekly on Mondays and Wednesdays 00:00
- cron: '00 00 * * MON,WED'
push:
branches: [main, rel-*]
pull_request:
branches: [main, rel-*]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
release:
if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'rel-') || contains(github.event.pull_request.labels.*.name, 'run release CIs')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- name: Checkout ONNX Script
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python build dependencies
run: |
python -m pip install --upgrade pip build wheel
- name: Build ONNX Script wheel dev version
run: |
python -m build
if: (!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')))
- name: Build ONNX Script wheel release version
run: |
python -m build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
ONNX_SCRIPT_RELEASE: 1
- uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
- name: Install ONNX Script wheel
run: |
python -m pip install dist/*.whl
test-wheel:
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Checkout ONNX Script
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r requirements-dev.txt
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: Install wheel
run: |
python -m pip install dist/*.whl
- name: Run tests
run: |
python -m pytest -v -n auto
publish-dev:
needs: [release]
runs-on: ubuntu-latest
environment: PyPI Dev
# Publish only when it is a scheduled run (dev builds)
if: github.event_name == 'schedule' && !startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
# TODO: Check the version number is a dev version
- name: Publish dev version to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

publish-release:
needs: [release]
runs-on: ubuntu-latest
environment: PyPI
# Publish only when it is a tag push with version number
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
# TODO: Check the tag name matches the VERSION file
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"beartype",
"types-PyYAML",
"expecttest",
"hypothesis",
"packaging",
"parameterized",
"pytest-cov",
Expand Down
10 changes: 5 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
numpy
onnx-weekly
setuptools>=61.0.0
--pre -f https://onnxruntimepackages.z14.web.core.windows.net/onnxruntime-function-experiment.html
ort-function-experiment-nightly
numpy
onnx-weekly==1.14.0.dev20230403
onnxruntime
typing_extensions

# Docs site
Expand All @@ -17,6 +16,7 @@ beartype

# Testing
expecttest
hypothesis
parameterized
pytest-cov
pytest-randomly
Expand All @@ -28,4 +28,4 @@ torch>=1.13

# Lint
lintrunner
lintrunner_adapters>=0.6.1
lintrunner_adapters>=0.7.0

0 comments on commit ba0ff2e

Please sign in to comment.