Add Forgejo upload script and update documentation for package registry
This commit is contained in:
parent
2be62e36fd
commit
9c8ddfdc8a
5 changed files with 160 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -15,6 +15,7 @@ dist/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
.eggs/
|
.eggs/
|
||||||
pip-wheel-metadata/
|
pip-wheel-metadata/
|
||||||
|
.pypirc
|
||||||
|
|
||||||
# Test and coverage output
|
# Test and coverage output
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
|
|
|
||||||
7
.pypirc.example
Normal file
7
.pypirc.example
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[distutils]
|
||||||
|
index-servers = forgejo
|
||||||
|
|
||||||
|
[forgejo]
|
||||||
|
repository = https://git.him-tools.de/api/packages/HIM-public/pypi
|
||||||
|
username = __token__
|
||||||
|
password = YOUR_FORGEJO_ACCESS_TOKEN
|
||||||
20
README.md
20
README.md
|
|
@ -69,6 +69,26 @@ Set the version and build the wheel in one step:
|
||||||
& .\.venv\Scripts\python.exe .\scripts\build_wheel.py --version 0.1.1
|
& .\.venv\Scripts\python.exe .\scripts\build_wheel.py --version 0.1.1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Upload the wheel to the Forgejo package registry:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
Force a rebuild before upload:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1 -Build
|
||||||
|
```
|
||||||
|
|
||||||
|
Build a specific version and upload it:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1 -Build -Version 0.1.1
|
||||||
|
```
|
||||||
|
|
||||||
|
Create `.pypirc` in the project root from `.pypirc.example` and fill in your Forgejo token before uploading.
|
||||||
|
|
||||||
Create a client with your eBay credentials:
|
Create a client with your eBay credentials:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ dev = [
|
||||||
"datamodel-code-generator>=0.28,<0.31",
|
"datamodel-code-generator>=0.28,<0.31",
|
||||||
"pytest>=8,<9",
|
"pytest>=8,<9",
|
||||||
"pytest-httpx>=0.35,<0.36",
|
"pytest-httpx>=0.35,<0.36",
|
||||||
|
"twine>=6,<7",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
|
|
|
||||||
131
upload_wheel_to_forgejo_pypi.ps1
Normal file
131
upload_wheel_to_forgejo_pypi.ps1
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
param(
|
||||||
|
[switch]$Build = $false,
|
||||||
|
[string]$Version,
|
||||||
|
[switch]$Help = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
Set-StrictMode -Version Latest
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
function Show-Help {
|
||||||
|
Write-Host @"
|
||||||
|
Upload wheel to the Forgejo PyPI registry for ebay-rest-client
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1 [-Build] [-Version <version>]
|
||||||
|
|
||||||
|
OPTIONS:
|
||||||
|
-Build Force a rebuild before uploading
|
||||||
|
-Version <version> Set the package version before building
|
||||||
|
-Help Display this help message
|
||||||
|
|
||||||
|
SETUP:
|
||||||
|
1. Copy .pypirc.example to .pypirc in the project root
|
||||||
|
2. Add your Forgejo access token to .pypirc
|
||||||
|
3. Run this script again
|
||||||
|
|
||||||
|
EXAMPLES:
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1 -Build
|
||||||
|
.\upload_wheel_to_forgejo_pypi.ps1 -Build -Version 0.1.1
|
||||||
|
"@
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Help) {
|
||||||
|
Show-Help
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
|
$python = Join-Path $projectRoot ".venv\Scripts\python.exe"
|
||||||
|
$pypiRcPath = Join-Path $projectRoot ".pypirc"
|
||||||
|
$buildScript = Join-Path $projectRoot "scripts\build_wheel.py"
|
||||||
|
$distPath = Join-Path $projectRoot "dist"
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================================================"
|
||||||
|
Write-Host "eBay REST Client - Upload to Forgejo PyPI"
|
||||||
|
Write-Host "========================================================================"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
if (!(Test-Path $python)) {
|
||||||
|
Write-Host "[!] Virtual environment Python not found at .venv\\Scripts\\python.exe" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path $pypiRcPath)) {
|
||||||
|
Write-Host "[!] .pypirc not found in project root." -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Setup instructions:"
|
||||||
|
Write-Host " 1. Copy .pypirc.example to .pypirc"
|
||||||
|
Write-Host " 2. Edit .pypirc and add your Forgejo access token"
|
||||||
|
Write-Host " 3. Run this script again"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "For help: .\upload_wheel_to_forgejo_pypi.ps1 -Help"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path $buildScript)) {
|
||||||
|
Write-Host "[!] Build script not found at scripts\\build_wheel.py" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = & $python -c "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec('twine') else 1)"
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Host "Installing twine..."
|
||||||
|
& $python -m pip install twine
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Host "[!] Failed to install twine." -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$wheelFiles = @(Get-ChildItem -Path $distPath -Filter "*.whl" -ErrorAction SilentlyContinue)
|
||||||
|
|
||||||
|
if ($Build -or $wheelFiles.Count -eq 0) {
|
||||||
|
if ($Build) {
|
||||||
|
Write-Host "Building wheel (forced)..."
|
||||||
|
} else {
|
||||||
|
Write-Host "Building wheel..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$buildArgs = @($buildScript)
|
||||||
|
if ($Version) {
|
||||||
|
$buildArgs += "--version"
|
||||||
|
$buildArgs += $Version
|
||||||
|
}
|
||||||
|
|
||||||
|
& $python @buildArgs
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Host "[!] Wheel build failed." -ForegroundColor Red
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
|
$wheelFiles = @(Get-ChildItem -Path $distPath -Filter "*.whl" -ErrorAction Stop)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($wheelFiles.Count -eq 0) {
|
||||||
|
Write-Host "[!] No wheel files found in dist." -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================================================"
|
||||||
|
Write-Host "Uploading to Forgejo PyPI..."
|
||||||
|
Write-Host "========================================================================"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
& $python -m twine upload --config-file $pypiRcPath -r forgejo $wheelFiles.FullName
|
||||||
|
$uploadResult = $LASTEXITCODE
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================================================"
|
||||||
|
if ($uploadResult -eq 0) {
|
||||||
|
Write-Host "Upload successful!" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "Upload failed" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
Write-Host "========================================================================"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
exit $uploadResult
|
||||||
Loading…
Add table
Add a link
Reference in a new issue