-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'Bump Versions' | ||
description: 'This action bumps versions of Cargo.toml and _version.py file, matching release tag' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Bump Cargo version | ||
# python ./cargo_version_bumper.py --target Cargo.toml "${{ github.ref_name }}" | ||
run: | | ||
python ./actions/bump_version/cargo_version_bumper.py --target Cargo.toml "0.0.1" | ||
shell: bash | ||
|
||
# - name: Check Cargo.toml version matches Release tag | ||
# run: | | ||
# CARGO_VERSION=$(grep '^version =' Cargo.toml | sed 's/.*"\(.*\)".*/\1/') | ||
# if [ "${GITHUB_REF#refs/tags/}" != "$CARGO_VERSION" ]; then | ||
# echo "Version mismatch: Cargo.toml ($CARGO_VERSION) doesn't match Release tag (${GITHUB_REF#refs/tags/})" | ||
# exit 1 | ||
# fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# From https://github.com/Intreecom/scyllapy/blob/05fdab32dd7468c26533de5fdfe9627fa3e38445/scripts/version_bumper.py | ||
|
||
import argparse | ||
import re | ||
from pathlib import Path | ||
|
||
|
||
def parse_args() -> argparse.Namespace: | ||
"""Parse command line arguments.""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--target", | ||
"-t", | ||
dest="target", | ||
type=Path, | ||
default="Cargo.toml", | ||
) | ||
parser.add_argument("version", type=str) | ||
return parser.parse_args() | ||
|
||
|
||
def main() -> None: | ||
"""Main function.""" | ||
args = parse_args() | ||
with args.target.open("r") as f: | ||
contents = f.read() | ||
|
||
contents = re.sub( | ||
r"version\s*=\s*\"(.*)\"", | ||
f'version = "{args.version}"', | ||
contents, | ||
count=1, | ||
) | ||
|
||
with args.target.open("w") as f: | ||
f.write(contents) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
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