Skip to content

workflow upload code change #3

workflow upload code change

workflow upload code change #3

Workflow file for this run

name: Sync Version and Publish
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Switch to main
run: |
git fetch origin main
git checkout main
- name: Update version from tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
python scripts/set_version.py $TAG_NAME
- name: Commit version bump
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add pytest_htmlx/__init__.py
git commit -m "chore: set version from $TAG_NAME" || echo "No changes to commit"
git push origin main
- name: Verify new version
run: grep __version__ pytest_htmlx/__init__.py
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
rm -rf dist/ build/ *.egg-info
python -m build
- name: Upload to TestPyPI
run: |
twine upload \
--repository-url https://test.pypi.org/legacy/ \
-u __token__ \
-p "$TEST_PYPI_API_TOKEN" \
dist/*
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Verify install from TestPyPI
run: |
python -m pip install --upgrade pip
pip install --index-url https://test.pypi.org/simple/ --no-deps pytest-htmlx
python -c "import pytest_htmlx; print(pytest_htmlx.__version__)"
- name: Publish to PyPI
run: |
twine upload \
-u __token__ \
-p "$PYPI_API_TOKEN" \
dist/*
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}