Skip to content

Commit 33dcae8

Browse files
committed
1.0.0
1 parent 61acf86 commit 33dcae8

File tree

2 files changed

+240
-3
lines changed

2 files changed

+240
-3
lines changed

DEVELOPMENT.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ This guide is for contributors and maintainers of `robotframework-jsonlib`.
99
| `run_ci_checks.sh` | Full CI validation (linting, tests, build) | `./run_ci_checks.sh` |
1010
| `run_tests_only.sh` | Fast test iteration | `./run_tests_only.sh` |
1111
| `run_build_only.sh` | Build and verify package | `./run_build_only.sh` |
12-
| `run_testpypi_upload.sh` | Upload to TestPyPI (not used in CI) | `./run_testpypi_upload.sh` |
12+
| `run_testpypi_upload.sh` | Upload to TestPyPI for testing | `./run_testpypi_upload.sh` |
13+
| `run_pypi_upload.sh` | Upload to production PyPI | `./run_pypi_upload.sh` |
1314

1415
All development scripts automatically create and use a Python virtual environment (`.venv`) to isolate dependencies.
1516

@@ -103,12 +104,18 @@ This script will:
103104

104105
### Publishing to Production PyPI
105106

106-
After testing with TestPyPI, publish to production PyPI:
107+
After testing with TestPyPI, publish to production PyPI using the upload script:
107108

108109
```bash
109-
twine upload dist/*
110+
./run_pypi_upload.sh
110111
```
111112

113+
This script will:
114+
- Build the package (if needed)
115+
- Prompt for confirmation before uploading
116+
- Upload to production PyPI
117+
- Provide next steps and installation instructions
118+
112119
**Prerequisites:**
113120
1. Register at [https://pypi.org/account/register/](https://pypi.org/account/register/)
114121
2. Generate an API token at [https://pypi.org/manage/account/token/](https://pypi.org/manage/account/token/)
@@ -119,6 +126,14 @@ twine upload dist/*
119126
password = <your PyPI API Token>
120127
```
121128

129+
**Options:**
130+
- `--no-build` - Skip building, use existing dist/ files
131+
132+
**Alternative:** You can also use twine directly:
133+
```bash
134+
twine upload dist/*
135+
```
136+
122137
## Virtual Environment
123138

124139
The virtual environment will remain active after the scripts complete. To deactivate it:

run_pypi_upload.sh

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
#!/bin/bash
2+
3+
# PyPI Upload Script for robotframework-jsonlib
4+
# Uploads the package to production PyPI
5+
#
6+
# Prerequisites:
7+
# 1. Register an account at https://pypi.org/account/register/
8+
# 2. Generate an API token at https://pypi.org/manage/account/token/
9+
# 3. Configure ~/.pypirc with:
10+
# [pypi]
11+
# username = __token__
12+
# password = <your PyPI API Token>
13+
#
14+
# Usage:
15+
# ./run_pypi_upload.sh # Build and upload to PyPI
16+
# ./run_pypi_upload.sh --no-build # Skip building (use existing dist/)
17+
18+
set -eo pipefail
19+
20+
# Colors for output
21+
RED='\033[0;31m'
22+
GREEN='\033[0;32m'
23+
YELLOW='\033[1;33m'
24+
BLUE='\033[0;34m'
25+
NC='\033[0m' # No Color
26+
27+
# Function to print success
28+
print_success() {
29+
echo -e "${GREEN}$1${NC}"
30+
}
31+
32+
# Function to print error
33+
print_error() {
34+
echo -e "${RED}$1${NC}"
35+
}
36+
37+
# Function to print info
38+
print_info() {
39+
echo -e "${YELLOW}$1${NC}"
40+
}
41+
42+
# Function to print warning
43+
print_warning() {
44+
echo -e "${YELLOW}$1${NC}"
45+
}
46+
47+
# Get script directory
48+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
49+
cd "$SCRIPT_DIR"
50+
51+
# Parse arguments
52+
SKIP_BUILD=false
53+
54+
for arg in "$@"; do
55+
case $arg in
56+
--no-build)
57+
SKIP_BUILD=true
58+
shift
59+
;;
60+
*)
61+
echo "Unknown argument: $arg"
62+
echo "Usage: $0 [--no-build]"
63+
exit 1
64+
;;
65+
esac
66+
done
67+
68+
# ================================
69+
# Setup
70+
# ================================
71+
VENV_DIR=".venv"
72+
73+
if [ -d "$VENV_DIR" ]; then
74+
echo "Using existing virtual environment..."
75+
else
76+
echo "Creating virtual environment..."
77+
python -m venv "$VENV_DIR"
78+
fi
79+
80+
echo "Activating virtual environment..."
81+
source "$VENV_DIR/bin/activate"
82+
83+
echo "Installing/upgrading build tools..."
84+
python -m pip install --upgrade pip > /dev/null 2>&1
85+
python -m pip install --upgrade build twine > /dev/null 2>&1
86+
print_success "Build tools ready"
87+
echo ""
88+
89+
# ================================
90+
# Build Package (unless --no-build)
91+
# ================================
92+
if [ "$SKIP_BUILD" = false ]; then
93+
echo -e "${BLUE}Building Package...${NC}"
94+
echo ""
95+
96+
print_info "Running build..."
97+
bash run_build_only.sh --no-setup
98+
echo ""
99+
else
100+
print_info "Skipping build (using existing dist/)..."
101+
102+
# Verify dist directory exists
103+
if [ ! -d "dist" ] || [ -z "$(ls -A dist 2>/dev/null)" ]; then
104+
print_error "No distribution files found in dist/"
105+
print_info "Run without --no-build flag to build the package first"
106+
exit 1
107+
fi
108+
print_success "Found existing distribution files"
109+
echo ""
110+
fi
111+
112+
# ================================
113+
# Final Checks Before Upload
114+
# ================================
115+
echo -e "${BLUE}Pre-Upload Checks...${NC}"
116+
echo ""
117+
118+
# Extract version from dist filename (compatible with both GNU and BSD)
119+
VERSION=$(ls dist/*.whl | head -1 | sed -E 's/.*-([0-9]+\.[0-9]+\.[0-9]+).*/\1/' || echo "unknown")
120+
121+
print_info "Package version: $VERSION"
122+
123+
# Check if this version already exists on PyPI
124+
echo ""
125+
print_warning "IMPORTANT: This will upload to PRODUCTION PyPI!"
126+
echo ""
127+
echo -e "${YELLOW}Package: robotframework-jsonlib${NC}"
128+
echo -e "${YELLOW}Version: $VERSION${NC}"
129+
echo ""
130+
echo -e "${RED}⚠️ WARNING: This action cannot be undone!${NC}"
131+
echo -e "${RED}⚠️ Versions cannot be re-uploaded once published.${NC}"
132+
echo ""
133+
read -p "Are you sure you want to upload to production PyPI? (yes/no): " -r
134+
echo ""
135+
136+
if [[ ! $REPLY =~ ^[Yy][Ee][Ss]$ ]]; then
137+
echo "Upload cancelled."
138+
exit 0
139+
fi
140+
141+
# ================================
142+
# Check PyPI Configuration
143+
# ================================
144+
print_info "Checking .pypirc configuration..."
145+
if [ ! -f ~/.pypirc ]; then
146+
print_warning "~/.pypirc not found"
147+
echo ""
148+
echo -e "${YELLOW}To avoid entering credentials each time, create ~/.pypirc with:${NC}"
149+
echo ""
150+
echo "[pypi]"
151+
echo "username = __token__"
152+
echo "password = <your PyPI API Token>"
153+
echo ""
154+
echo -e "${YELLOW}Get your token at: https://pypi.org/manage/account/token/${NC}"
155+
echo ""
156+
elif ! grep -q "\[pypi\]" ~/.pypirc; then
157+
print_warning "PyPI not configured in ~/.pypirc"
158+
echo ""
159+
echo -e "${YELLOW}Add this section to ~/.pypirc:${NC}"
160+
echo ""
161+
echo "[pypi]"
162+
echo "username = __token__"
163+
echo "password = <your PyPI API Token>"
164+
echo ""
165+
echo -e "${YELLOW}Get your token at: https://pypi.org/manage/account/token/${NC}"
166+
echo ""
167+
else
168+
print_success "Found PyPI configuration in ~/.pypirc"
169+
fi
170+
171+
# ================================
172+
# Upload to PyPI
173+
# ================================
174+
echo -e "${BLUE}Uploading to Production PyPI...${NC}"
175+
echo ""
176+
177+
print_info "Uploading to PyPI..."
178+
echo ""
179+
180+
# Upload with explicit error handling
181+
if twine upload dist/*; then
182+
print_success "Upload successful!"
183+
echo ""
184+
185+
echo -e "${GREEN}Package uploaded successfully to PyPI!${NC}"
186+
echo ""
187+
echo -e "${YELLOW}View your package at:${NC}"
188+
echo " https://pypi.org/project/robotframework-jsonlib/"
189+
echo ""
190+
echo -e "${YELLOW}Your package will be available for installation in a few minutes:${NC}"
191+
echo " pip install robotframework-jsonlib"
192+
echo ""
193+
echo -e "${YELLOW}To install this specific version:${NC}"
194+
echo " pip install robotframework-jsonlib==$VERSION"
195+
echo ""
196+
else
197+
print_error "Upload failed"
198+
echo ""
199+
echo -e "${YELLOW}Common issues:${NC}"
200+
echo " 1. This version may already exist on PyPI (versions cannot be re-uploaded)"
201+
echo " 2. Check your credentials in ~/.pypirc"
202+
echo " 3. Ensure you have a PyPI account: https://pypi.org/account/register/"
203+
echo " 4. Verify your API token has upload permissions"
204+
echo ""
205+
echo -e "${YELLOW}For testing, use TestPyPI first:${NC}"
206+
echo " ./run_testpypi_upload.sh"
207+
echo ""
208+
exit 1
209+
fi
210+
211+
# ================================
212+
# Post-Upload Instructions
213+
# ================================
214+
echo -e "${GREEN}PyPI Upload Complete!${NC}"
215+
echo ""
216+
echo -e "${YELLOW}Next steps:${NC}"
217+
echo " 1. Verify package: https://pypi.org/project/robotframework-jsonlib/$VERSION/"
218+
echo " 2. Test installation: pip install robotframework-jsonlib==$VERSION"
219+
echo ""
220+
echo -e "${YELLOW}Note: Virtual environment is still active (.venv)${NC}"
221+
echo -e "${YELLOW}To deactivate, run: deactivate${NC}"
222+

0 commit comments

Comments
 (0)