Skip to content

Commit

Permalink
update workflows (#157)
Browse files Browse the repository at this point in the history
Add workflows for automatically publishing packages to PyPi.
  • Loading branch information
liu-jc authored Nov 28, 2024
1 parent c752af7 commit 16e6c9d
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This workflow will upload a Python Package to Pypi using Twine when a release is created in this Github repo.
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# Note: There is a bug in Github Actions, so do NOT use the “Save Draft” functionality when creating a new release: https://github.community/t/workflow-set-for-on-release-not-triggering-not-showing-up/16286/5
# Remember to always verify tagged releases are actually available on the Pypi website: https://pypi.org/project/autogluon/

name: Publish Package

on:
release:
types: [created]

jobs:
validate-publish-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install tools
run: |
python -m pip install --upgrade pip
pip install hatch twine check-wheel-contents
- name: Build package
run: |
hatch build
- name: Run package validators
run: |
twine check dist/*
check-wheel-contents dist/*.whl
# Test install from wheel
pip install dist/*.whl
python -c "import uni2ts; print(uni2ts.__version__)"
# Test install from sdist
# pip uninstall -y uni2ts
# pip install dist/*.tar.gz
# python -c "import uni2ts; print(uni2ts.__version__)"
- name: Upload to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
run: |
twine upload --verbose dist/*
- name: Verify Test PyPI publication
run: |
sleep 60
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ uni2ts==${GITHUB_REF#refs/tags/v}
python -c "import uni2ts; print(uni2ts.__version__)"
publish-prod:
needs: validate-publish-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install tools
run: |
python -m pip install --upgrade pip
pip install hatch twine
- name: Build package
run: |
hatch build
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload --verbose dist/*
- name: Verify PyPI publication
run: |
sleep 60
pip install uni2ts==${GITHUB_REF#refs/tags/v}
python -c "import uni2ts; print(uni2ts.__version__)"
52 changes: 52 additions & 0 deletions .github/workflows/testpypi_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will upload a Python Package using Twine to Test PyPi (Full release) when a workflow_dispatch event is triggered.
# THIS IS MEANT AS A FINAL SANITY CHECK BEFORE RELEASE.

name: Test Publication Process

on: workflow_dispatch

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Modify version for test
run: |
VERSION=$(python -c "exec(open('src/uni2ts/__about__.py').read()); print(__version__)")
echo "__version__ = \"${VERSION}.dev$(date +%Y%m%d)\"" > src/uni2ts/__about__.py
cat src/uni2ts/__about__.py
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install hatch twine check-wheel-contents
- name: Build package
run: |
hatch build
- name: Run package validators
run: |
twine check dist/*
check-wheel-contents dist/*.whl
# Test install from wheel
pip install dist/*.whl
python -c "import uni2ts; print(uni2ts.__version__)"
- name: Test publish to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
run: |
twine upload --verbose dist/*
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ requires-python = ">=3.10"
authors = [
{name = "Gerald Woo", email = "[email protected]"},
{name = "Chenghao Liu", email = "[email protected]"},
{name = "Juncheng Liu", email = "[email protected]"},
{name = "Taha Aksu", email = "[email protected]"},
{name = "Xu Liu", email = "[email protected]"},
{name = "Akshat Kumar"},
{name = "Caiming Xiong"},
{name = "Silvio Savarese"},
Expand Down

0 comments on commit 16e6c9d

Please sign in to comment.