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