Skip to content

Commit 3ff9dd4

Browse files
committed
👷‍♂️ Extend publish_pypi with built_type
* built_type is added as a input property * available options: dev,release,nightly,custom * built types detemine the suffix for the package name * 'publisher' is renamed to 'pyblish_pypi'
1 parent f8b2496 commit 3ff9dd4

File tree

3 files changed

+107
-111
lines changed

3 files changed

+107
-111
lines changed
File renamed without changes.

actions/publish_pypi/action.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: "Build and publish the distribution to the PyPI server"
2+
description: "Build and publish PyPi wheel using tox for ML repos e.g. sparseml, compressed-tensors"
3+
4+
inputs:
5+
publish_pypi_internal:
6+
description: "Publish the distribution to the internal PyPI server"
7+
required: true
8+
9+
publish_pypi:
10+
description: "Publish the distribution to the pypi.org"
11+
required: true
12+
13+
built_type:
14+
description: "Applies a set of rules depending on the environment. Available values: (dev|release|nightly|custom)"
15+
required: true
16+
17+
custom_package_name:
18+
description: "Custom package name could be used along wtih the 'custom' build_type"
19+
required: false
20+
21+
outputs:
22+
whlname:
23+
description: "wheel filename"
24+
value: ${{ steps.build.outputs.whlname }}
25+
tarname:
26+
description: "tar.gz filename"
27+
value: ${{ steps.build.outputs.tarname }}
28+
29+
runs:
30+
using: "composite"
31+
32+
steps:
33+
- name: Install tox
34+
run: python3 -m pip install --user tox build
35+
36+
- name: Build the distribution with tox
37+
id: build
38+
run: |
39+
python3 -m tox -e build
40+
41+
# suffixes dispatcher
42+
SUFFIX=""
43+
case ${{ inputs.built_type }} in
44+
"dev")
45+
SUFFIX="-dev-${{ github.event.pull_request.number }}"
46+
;;
47+
"nightly")
48+
SUFFIX="-nightly-$(date +%Y%m%d)"
49+
;;
50+
"staging")
51+
;;
52+
"release")
53+
;;
54+
"custom")
55+
if [[ -z ${{ inputs.custom_package_name }} ]]; then
56+
echo "Error: Custom build_type requires a custom_package_name input"
57+
exit 1
58+
fi
59+
SUFFIX=""
60+
;;
61+
*)
62+
echo "Invalid build_type: ${{ inputs.built_type }}"
63+
exit 1
64+
esac
65+
66+
echo "::set-output name=suffix::$SUFFIX"
67+
68+
- name: Rename build artifacts
69+
run: |
70+
# Retrieve package name from previous step
71+
PACKAGE_NAME="${{ inputs.custom_package_name || 'guidellm' }}"
72+
73+
# Extract version from distribution file name (e.g., guidellm-1.2.3-dev.whl)
74+
VERSION=$(find dist -name "*.whl" | cut -d '-' -f 2)
75+
76+
# Generate final file name based on build_type and package name
77+
NEW_NAME="${PACKAGE_NAME}${SUFFIX}-${VERSION}.whl"
78+
TAR_NAME="${PACKAGE_NAME}${SUFFIX}-${VERSION}.tar.gz"
79+
80+
mv dist/* dist/$NEW_NAME
81+
cp dist/$NEW_NAME dist/$TAR_NAME
82+
83+
# Set outputs for subsequent steps
84+
echo "::set-output name=whlname::$NEW_NAME"
85+
echo "::set-output name=tarname::$TAR_NAME"
86+
87+
- name: Authenticate to GCP
88+
uses: google-github-actions/auth@v2.1.3
89+
with:
90+
project_id: ${{ secrets.GCP_PROJECT }}
91+
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
92+
service_account: ${{ secrets.NM_PYPI_SA }}
93+
94+
- name: Upload to Internal PyPI
95+
if: ${{ inputs.publish_pypi_internal }}
96+
uses: neuralmagic/nm-actions/actions/gcp-upload-asset@v1.1.0
97+
with:
98+
bucket_target: ${{ secrets.GCP_NM_PYPI_DIST }}
99+
asset: ${{ steps.build.outputs.whlname }}
100+
101+
- name: Publish to Public PyPI
102+
if: ${{ inputs.publish_pypi }}
103+
uses: neuralmagic/nm-actions/actions/publish-whl@v1.0.0
104+
with:
105+
username: ${{ secrets.PYPI_PUBLIC_USER }}
106+
password: ${{ secrets.PYPI_PUBLIC_AUTH }}
107+
whl: ${{ steps.build.outputs.whlname }}

actions/publisher/action.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)