Add build number to test publish package version #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test publish | |
on: push | |
permissions: | |
contents: read | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: test-pypi | |
url: https://test.pypi.org/project/copyright2 | |
permissions: | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip toml | |
pip install build | |
- name: Add build number to package version | |
shell: python | |
run: | | |
import toml | |
with open("pyproject.toml", "r") as f: | |
data = toml.load(f) | |
data["project"]["version"] = f'{data["project"]["version"]}.dev${{ github.run_id }}' | |
with open("pyproject.toml", "w") as f: | |
toml.dump(data, f) | |
- name: Build package | |
run: python -m build | |
- name: Publish package | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true |