Skip to content

Commit 16e6c9d

Browse files
authored
update workflows (#157)
Add workflows for automatically publishing packages to PyPi.
1 parent c752af7 commit 16e6c9d

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

.github/workflows/pypi_publish.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This workflow will upload a Python Package to Pypi using Twine when a release is created in this Github repo.
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
# 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
4+
# Remember to always verify tagged releases are actually available on the Pypi website: https://pypi.org/project/autogluon/
5+
6+
name: Publish Package
7+
8+
on:
9+
release:
10+
types: [created]
11+
12+
jobs:
13+
validate-publish-test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Install tools
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install hatch twine check-wheel-contents
29+
30+
- name: Build package
31+
run: |
32+
hatch build
33+
34+
- name: Run package validators
35+
run: |
36+
twine check dist/*
37+
check-wheel-contents dist/*.whl
38+
39+
# Test install from wheel
40+
pip install dist/*.whl
41+
python -c "import uni2ts; print(uni2ts.__version__)"
42+
43+
# Test install from sdist
44+
# pip uninstall -y uni2ts
45+
# pip install dist/*.tar.gz
46+
# python -c "import uni2ts; print(uni2ts.__version__)"
47+
48+
- name: Upload to Test PyPI
49+
env:
50+
TWINE_USERNAME: __token__
51+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
52+
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
53+
run: |
54+
twine upload --verbose dist/*
55+
56+
- name: Verify Test PyPI publication
57+
run: |
58+
sleep 60
59+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ uni2ts==${GITHUB_REF#refs/tags/v}
60+
python -c "import uni2ts; print(uni2ts.__version__)"
61+
62+
publish-prod:
63+
needs: validate-publish-test
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Set up Python
71+
uses: actions/setup-python@v5
72+
with:
73+
python-version: '3.10'
74+
75+
- name: Install tools
76+
run: |
77+
python -m pip install --upgrade pip
78+
pip install hatch twine
79+
80+
- name: Build package
81+
run: |
82+
hatch build
83+
84+
- name: Upload to PyPI
85+
env:
86+
TWINE_USERNAME: __token__
87+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
88+
run: |
89+
twine upload --verbose dist/*
90+
91+
- name: Verify PyPI publication
92+
run: |
93+
sleep 60
94+
pip install uni2ts==${GITHUB_REF#refs/tags/v}
95+
python -c "import uni2ts; print(uni2ts.__version__)"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow will upload a Python Package using Twine to Test PyPi (Full release) when a workflow_dispatch event is triggered.
2+
# THIS IS MEANT AS A FINAL SANITY CHECK BEFORE RELEASE.
3+
4+
name: Test Publication Process
5+
6+
on: workflow_dispatch
7+
8+
jobs:
9+
validate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.10'
20+
21+
- name: Modify version for test
22+
run: |
23+
VERSION=$(python -c "exec(open('src/uni2ts/__about__.py').read()); print(__version__)")
24+
echo "__version__ = \"${VERSION}.dev$(date +%Y%m%d)\"" > src/uni2ts/__about__.py
25+
cat src/uni2ts/__about__.py
26+
27+
- name: Install tools
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install hatch twine check-wheel-contents
31+
32+
- name: Build package
33+
run: |
34+
hatch build
35+
36+
- name: Run package validators
37+
run: |
38+
twine check dist/*
39+
check-wheel-contents dist/*.whl
40+
41+
# Test install from wheel
42+
pip install dist/*.whl
43+
python -c "import uni2ts; print(uni2ts.__version__)"
44+
45+
46+
- name: Test publish to Test PyPI
47+
env:
48+
TWINE_USERNAME: __token__
49+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
50+
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
51+
run: |
52+
twine upload --verbose dist/*

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ requires-python = ">=3.10"
2929
authors = [
3030
{name = "Gerald Woo", email = "gwoo@salesforce.com"},
3131
{name = "Chenghao Liu", email = "chenghao.liu@salesforce.com"},
32+
{name = "Juncheng Liu", email = "juncheng.liu@salesforce.com"},
33+
{name = "Taha Aksu", email = "iaksu@salesforce.com"},
34+
{name = "Xu Liu", email = "xu.liu@salesforce.com"},
3235
{name = "Akshat Kumar"},
3336
{name = "Caiming Xiong"},
3437
{name = "Silvio Savarese"},

0 commit comments

Comments
 (0)