Skip to content

Commit 4ca63e8

Browse files
authored
Update publish workflow for tag checking (#2632)
1 parent 13a3993 commit 4ca63e8

File tree

3 files changed

+109
-25
lines changed

3 files changed

+109
-25
lines changed

.github/workflows/publish.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and upload to internal PyPI
1+
name: Build and upload to PyPI
22

33
on:
44
workflow_dispatch: # run on request (no need for PR)
@@ -40,22 +40,17 @@ jobs:
4040
name: Publish package
4141
needs: [build_wheels, build_sdist]
4242
environment: pypi
43-
runs-on: [self-hosted, linux, x64, dev]
43+
runs-on: ubuntu-latest
4444
permissions: write-all
4545
steps:
46-
- name: Set up Python
47-
uses: actions/setup-python@v4
48-
with:
49-
python-version: "3.10"
50-
- name: Install dependencies
51-
run: python -m pip install twine
5246
- name: Download artifacts
5347
uses: actions/download-artifact@v3
5448
with:
5549
# unpacks default artifact into dist/
5650
# if `name: artifact` is omitted, the action will create extra parent dir
5751
name: artifact
5852
path: dist
53+
# to determine where to publish the source distribution to PyPI or TestPyPI
5954
- name: Check tag
6055
id: check-tag
6156
uses: actions-ecosystem/action-regex-match@v2
@@ -71,18 +66,15 @@ jobs:
7166
tag: ${{ github.ref }}
7267
overwrite: true
7368
file_glob: true
74-
- name: Check dist contents
75-
run: twine check dist/*
76-
- name: Publish package dist to internal PyPI
77-
run: |
78-
export no_proxy=${{ secrets.PYPI_HOST }}
79-
export REPOSITORY_URL=http://${{ secrets.PYPI_HOST }}:${{ secrets.PYPI_PORT }}
80-
twine upload --verbose --repository-url $REPOSITORY_URL dist/* -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }}
81-
- name: Clean up dist
82-
if: ${{ always() }}
83-
run: |
84-
if OUTPUT=$(ls | grep -c dist)
85-
then
86-
echo "Cleaning up dist directory"
87-
rm -r dist
88-
fi
69+
- name: Publish package distributions to PyPI
70+
if: ${{ steps.check-tag.outputs.match != '' }}
71+
uses: pypa/[email protected]
72+
with:
73+
password: ${{ secrets.PYPI_API_TOKEN }}
74+
- name: Publish package distributions to TestPyPI
75+
if: ${{ steps.check-tag.outputs.match == '' }}
76+
uses: pypa/[email protected]
77+
with:
78+
password: ${{ secrets.TESTPYPI_API_TOKEN }}
79+
repository-url: https://test.pypi.org/legacy/
80+
verbose: true
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build and upload to internal PyPI
2+
3+
on:
4+
workflow_dispatch: # run on request (no need for PR)
5+
6+
jobs:
7+
build_wheels:
8+
name: Build wheels
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
- name: Build wheels
14+
uses: pypa/[email protected]
15+
- uses: actions/upload-artifact@v3
16+
with:
17+
path: ./wheelhouse/*.whl
18+
19+
build_sdist:
20+
name: Build source distribution
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Set up Python 3.10
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: "3.10"
29+
- name: Install pypa/build
30+
run: python -m pip install build
31+
- name: Build sdist
32+
run: python -m build --sdist
33+
- uses: actions/upload-artifact@v3
34+
with:
35+
path: dist/*.tar.gz
36+
37+
publish_package:
38+
name: Publish package
39+
needs: [build_wheels, build_sdist]
40+
environment: pypi
41+
runs-on: [self-hosted, linux, x64, dev]
42+
permissions: write-all
43+
steps:
44+
- name: Set up Python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: "3.10"
48+
- name: Install dependencies
49+
run: python -m pip install twine
50+
- name: Download artifacts
51+
uses: actions/download-artifact@v3
52+
with:
53+
# unpacks default artifact into dist/
54+
# if `name: artifact` is omitted, the action will create extra parent dir
55+
name: artifact
56+
path: dist
57+
- name: Check tag
58+
id: check-tag
59+
uses: actions-ecosystem/action-regex-match@v2
60+
with:
61+
text: ${{ github.ref }}
62+
regex: '^refs/heads/releases/[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+rc[0-9]+|rc[0-9]+)?$'
63+
- name: Upload package distributions to github
64+
if: ${{ steps.check-tag.outputs.match != '' }}
65+
uses: svenstaro/upload-release-action@v2
66+
with:
67+
repo_token: ${{ secrets.GITHUB_TOKEN }}
68+
file: dist/*
69+
tag: ${{ github.ref }}
70+
overwrite: true
71+
file_glob: true
72+
- name: Check dist contents
73+
run: twine check dist/*
74+
- name: Publish package dist to internal PyPI
75+
if: ${{ steps.check-tag.outputs.match != '' }}
76+
run: |
77+
export no_proxy=${{ secrets.PYPI_HOST }}
78+
export REPOSITORY_URL=http://${{ secrets.PYPI_HOST }}:${{ secrets.PYPI_PORT }}
79+
twine upload --verbose --repository-url $REPOSITORY_URL dist/* -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }}
80+
- name: Publish package distributions to TestPyPI
81+
if: ${{ steps.check-tag.outputs.match == '' }}
82+
run: |
83+
export REPOSITORY_URL=https://test.pypi.org/legacy/
84+
twine upload --verbose --repository-url $REPOSITORY_URL dist/* -u __token__ -p ${{ secrets.TESTPYPI_API_TOKEN }}
85+
- name: Clean up dist
86+
if: ${{ always() }}
87+
run: |
88+
if OUTPUT=$(ls | grep -c dist)
89+
then
90+
echo "Cleaning up dist directory"
91+
rm -r dist
92+
fi

requirements/base.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2-
# Base Algo Requirements. #
2+
# Base Algo Requirements. #
33
natsort==8.1.*
44
prettytable==3.9.*
55
protobuf==3.20.*
66
pyyaml
7-
datumaro==1.5.1rc3
7+
datumaro~=1.5.1rc4
88
psutil==5.9.*
99
scipy==1.10.*
1010
bayesian-optimization==1.4.*

0 commit comments

Comments
 (0)