-
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.
Add test header and semver ci (#304)
* header and semver ci * format * format * fix * fix * fix * auto update semantic version * update ci * fix * auto update semantic version * refine --------- Co-authored-by: wjymtg <[email protected]>
- Loading branch information
Showing
5 changed files
with
70 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,40 @@ | ||
name: Semantic Versioning | ||
|
||
on: | ||
pull_request: | ||
types: [ labeled ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
update-semver: | ||
if: contains(fromJSON('["major", "minor", "patch"]'), github.event.label.name) | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: pip install semver argparse | ||
|
||
- name: Get PR labels | ||
id: pr-labels | ||
uses: joerick/[email protected] | ||
|
||
- name: Increment SemVer | ||
run: | | ||
python increment_version.py --labels ${{steps.pr-labels.outputs.labels}} | ||
- name: Commit SemVer | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "auto update semantic version" |
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,23 @@ | ||
import argparse | ||
|
||
import semver | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--labels", type=str) | ||
args = vars(parser.parse_args()) | ||
print(f"args: {args}") | ||
|
||
with open("version.txt", "r+") as file: | ||
current_semver_str = file.read() | ||
print(f"current ver: {current_semver_str}") | ||
ver = semver.Version.parse(current_semver_str) | ||
if "patch" in args["labels"]: | ||
ver = ver.bump_patch() | ||
if "minor" in args["labels"]: | ||
ver = ver.bump_minor() | ||
if "major" in args["labels"]: | ||
ver = ver.bump_major() | ||
print(f"new ver: {ver}") | ||
file.seek(0) | ||
file.write(str(ver)) | ||
file.truncate() |
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
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 @@ | ||
0.4.2 |