From cadebd82106e32409b7854b033dbd7a68de87fc0 Mon Sep 17 00:00:00 2001 From: Juncheng Liu Date: Wed, 4 Dec 2024 10:40:24 +0800 Subject: [PATCH] update workflow (#160) Add a workflow to manually publish to pypi --- .github/workflows/pypi_publish.yml | 10 ++++- .github/workflows/pypi_publish_manual.yml | 51 +++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pypi_publish_manual.yml diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml index affd946..7d8288a 100644 --- a/.github/workflows/pypi_publish.yml +++ b/.github/workflows/pypi_publish.yml @@ -55,7 +55,10 @@ jobs: - 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} + # Extract version from tag + VERSION=${GITHUB_REF#refs/tags/} # removes refs/tags/ + echo "Installing version: $VERSION" + pip install --index-url https://test.pypi.org/simple/ uni2ts==${VERSION} python -c "import uni2ts; print(uni2ts.__version__)" publish-prod: @@ -90,5 +93,8 @@ jobs: - name: Verify PyPI publication run: | sleep 60 - pip install uni2ts==${GITHUB_REF#refs/tags/v} + # Extract version from tag + VERSION=${GITHUB_REF#refs/tags/} # removes refs/tags/ + echo "Installing version: $VERSION" + pip install uni2ts==$VERSION python -c "import uni2ts; print(uni2ts.__version__)" \ No newline at end of file diff --git a/.github/workflows/pypi_publish_manual.yml b/.github/workflows/pypi_publish_manual.yml new file mode 100644 index 0000000..166205a --- /dev/null +++ b/.github/workflows/pypi_publish_manual.yml @@ -0,0 +1,51 @@ +# This workflow will upload a Python Package using Twine to Test PyPi (Full release) when a workflow_dispatch event is triggered. + +name: Manually Publish Package + +on: workflow_dispatch + +jobs: + publish: + 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: Run package validators + run: | + twine check dist/* + + # Test install from wheel + pip install dist/*.whl + python -c "import uni2ts; print(uni2ts.__version__)" + + - 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 + # Extract version from tag + VERSION=${GITHUB_REF#refs/tags/} # removes refs/tags/ + echo "Installing version: $VERSION" + pip install uni2ts==$VERSION + python -c "import uni2ts; print(uni2ts.__version__)" \ No newline at end of file