From 1ce185912a9cdde474a702a8a90352da161c25e5 Mon Sep 17 00:00:00 2001 From: Juncheng Liu Date: Thu, 28 Nov 2024 14:44:41 +0800 Subject: [PATCH] update workflows --- .github/workflows/pypi_publish.yml | 95 ++++++++++++++++++++++++++ .github/workflows/testpypi_publish.yml | 52 ++++++++++++++ pyproject.toml | 3 + 3 files changed, 150 insertions(+) create mode 100644 .github/workflows/pypi_publish.yml create mode 100644 .github/workflows/testpypi_publish.yml diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml new file mode 100644 index 00000000..9bad7dea --- /dev/null +++ b/.github/workflows/pypi_publish.yml @@ -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__)" \ No newline at end of file diff --git a/.github/workflows/testpypi_publish.yml b/.github/workflows/testpypi_publish.yml new file mode 100644 index 00000000..ef146196 --- /dev/null +++ b/.github/workflows/testpypi_publish.yml @@ -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/* \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f2430afa..f8c0c1f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,9 @@ requires-python = ">=3.10" authors = [ {name = "Gerald Woo", email = "gwoo@salesforce.com"}, {name = "Chenghao Liu", email = "chenghao.liu@salesforce.com"}, + {name = "Juncheng Liu", email = "juncheng.liu@salesforce.com"}, + {name = "Taha Aksu", email = "iaksu@salesforce.com"}, + {name = "Xu Liu", email = "xu.liu@salesforce.com"}, {name = "Akshat Kumar"}, {name = "Caiming Xiong"}, {name = "Silvio Savarese"},