Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 12 additions & 0 deletions bin/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Loading