diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 44df14e3..0a7f72a2 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -12,6 +12,11 @@ on: - minor - patch default: 'patch' + alpha: + description: 'Append an -alpha suffix, to open a development cycle' + required: false + type: boolean + default: false jobs: bump-version: @@ -47,10 +52,20 @@ jobs: id: bump_version run: | BUMP_TYPE=${{ github.event.inputs.bump_type }} - VERSION=$(python3 bin/bump_version.py pyqasm $BUMP_TYPE) - python3 bin/update_citation.py $VERSION + + if [[ "${{ inputs.alpha }}" == "true" ]]; then + # An alpha version is not a release, so CITATION.cff keeps + # describing the last one until that release ships. + VERSION=$(python3 bin/bump_version.py pyqasm $BUMP_TYPE --alpha) + FILES="pyproject.toml" + else + VERSION=$(python3 bin/bump_version.py pyqasm $BUMP_TYPE) + python3 bin/update_citation.py $VERSION + FILES="pyproject.toml CITATION.cff" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT - git add pyproject.toml CITATION.cff + git add $FILES git commit -m "Bump $BUMP_TYPE version to $VERSION" git push origin qbraid-bot/${{ github.run_id }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 736421bc..33c05370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Types of changes: ### Dependencies ### Other +- Added an `alpha` input to the `Bump Version` workflow, off by default. It appends an `-alpha` suffix to the bumped version and leaves `CITATION.cff` alone, since an alpha is not a release. The suffix is what lets successive pre-releases stamp a0, a1, a2: without it the stamper returns a0 every time, and a version equal to a released one yields a pre-release that collides with files already on PyPI. Because the bump is computed from the latest release, the result always sits above it. ([#415](https://github.com/qBraid/pyqasm/pull/415)) - Switched PyPI publishing from a long-lived `PYPI_API_TOKEN` repository secret to trusted publishing. The publish job now mints a short-lived OIDC credential scoped to that one workflow, and the action attaches PEP 740 attestations recording the repository, workflow and commit SHA behind each uploaded file. Attestations apply to releases published after this merges, not retroactively. ([#411](https://github.com/qBraid/pyqasm/pull/411)) - Fixed the pre-release build stamping a version that `pyqasm.__version__` and the package metadata spelled differently. `pre_build.sh` wrote `1.1.0-a.0` into `pyproject.toml`, setuptools normalized that to `1.1.0a0` for the metadata, and `_version.py` kept the raw string, so `pip show pyqasm` and `pyqasm.__version__` disagreed and `test_sdist.sh` failed its version check. The stamped version is now normalized to PEP 440 before it is written. ([#414](https://github.com/qBraid/pyqasm/pull/414)) - Fixed the pre-release workflow publishing its source distribution under the released version instead of the pre-release one. `build_sdist.sh` ran `git reset --hard` and `git clean -xdf`, which discarded the `pyproject.toml` version that the preceding step had just stamped, so a run that built `1.1.0a0` wheels built a `1.1.0` sdist and PyPI rejected it as a duplicate. `pre_build.sh` already resets the tree, so the second reset is gone. It also no longer destroys uncommitted work when the script is run locally. ([#413](https://github.com/qBraid/pyqasm/pull/413)) diff --git a/bin/bump_version.py b/bin/bump_version.py index 74b9d2ce..0b3eb04d 100755 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -15,11 +15,16 @@ """ Script to bump the major, minor, or patch version in pyproject.toml. +Pass --alpha to append an -alpha suffix, which opens a development cycle. The +bumped version always sits above the latest release, so a pre-release built from +it can never collide with a version that is already live on PyPI. + """ import pathlib import sys +from packaging.version import Version from qbraid_core.system.versions import ( bump_version, get_latest_package_version, @@ -30,11 +35,18 @@ package_name = sys.argv[1] bump_type = sys.argv[2] + alpha = "--alpha" in sys.argv[3:] root = pathlib.Path(__file__).parent.parent.resolve() pyproject_toml_path = root / "pyproject.toml" current_version = get_latest_package_version(package_name) bumped_version = bump_version(current_version, bump_type) + + if alpha: + # base_version drops any suffix the bumped version already carries, so + # that the result is always exactly one -alpha and never 1.2.0-alpha-alpha + bumped_version = f"{Version(bumped_version).base_version}-alpha" + update_version_in_pyproject(pyproject_toml_path, bumped_version) print(bumped_version)