Skip to content

Commit 52ceaa9

Browse files
authored
Merge pull request #22 from aws/pypi-publish
Add GitHub workflow for publishing to pypi.
2 parents ed2288d + c77979d commit 52ceaa9

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish to PyPI
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
7+
on:
8+
release:
9+
types: [released]
10+
workflow_dispatch:
11+
inputs:
12+
confirm_publish:
13+
description: 'Confirm publishing to PyPI'
14+
required: true
15+
default: 'no'
16+
type: choice
17+
options:
18+
- 'yes'
19+
- 'no'
20+
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: '3.11'
33+
cache: 'pip'
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install build twine
39+
40+
- name: Verify version
41+
run: |
42+
VERSION=$(grep '^VERSION' src/amzn_nova_prompt_optimizer/__version__.py | cut -d '"' -f2)
43+
echo "Package version: $VERSION"
44+
45+
# Check if this version already exists on PyPI
46+
if pip index versions nova-prompt-optimizer 2>/dev/null | grep -q "^ *$VERSION$"; then
47+
echo "Error: Version $VERSION already exists on PyPI"
48+
exit 1
49+
fi
50+
echo "Version check passed: $VERSION is not on PyPI yet"
51+
52+
- name: Build package
53+
run: python -m build
54+
55+
- name: Check package
56+
run: twine check dist/*
57+
58+
- name: Publish to PyPI
59+
if: github.event_name == 'release' || github.event.inputs.confirm_publish == 'yes'
60+
env:
61+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
62+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
63+
run: twine upload dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ wheels/
2222
*.egg
2323

2424
# Virtual environments
25+
.venv/
2526
venv/
2627
env/
2728
ENV/

src/amzn_nova_prompt_optimizer/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
VERSION = "1.0.20250710152026" # pragma: no cover
14+
VERSION = "1.0.48" # pragma: no cover

0 commit comments

Comments
 (0)