From a76737aff0d9ebde97f5b45e54335265201e5fab Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:09:23 +0800 Subject: [PATCH 01/10] ci: use nguyenvukhang/semver-increment@v1 --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77b519e..7e75a9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,9 @@ jobs: # Sets the increment: how much to push the version number - run: | case ${{ github.ref_name }} in - main) echo "increment=release" >> $GITHUB_OUTPUT;; - dev) echo "increment=patch-pre" >> $GITHUB_OUTPUT;; - *) echo "increment=${{ github.ref_name }}-pre" >> $GITHUB_OUTPUT;; + main) echo "increment=patch" >> $GITHUB_OUTPUT ;; + dev) echo "increment=prerelease" >> $GITHUB_OUTPUT ;; + *) echo "increment=${{ github.ref_name }}" >> $GITHUB_OUTPUT;; esac id: increment @@ -69,18 +69,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: git fetch --tags - - run: make ci-git-user + - uses: nguyenvukhang/semver-increment@v1 + id: semver + with: + increment: ${{ matrix.increment }} + identifier: 'alpha' + version-file: "Cargo.toml" + version-regex: '^version = "(.*)"' - - name: Increment ${{ needs.pre.outputs.increment }} version - run: make py - env: - ARG: increment-${{ needs.pre.outputs.increment }} + - name: Commit and tag for v${{ steps.semver.outputs.version }} + run: | + cargo build + git add Cargo.toml Cargo.lock + git commit -m 'ver: bump to ${{ steps.semver.outputs.version }}' + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git tag v${{ steps.semver.outputs.version }} + git push --tag # publish patch-level updates and above only publish-crates-io: name: Publish to Crates.io - if: needs.pre.outputs.increment == 'release' + if: needs.pre.outputs.increment != 'prerelease' needs: [pre, increment] runs-on: ubuntu-latest steps: @@ -103,7 +113,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: ${{ needs.pre.outputs.increment == 'release' && format('v{0}', needs.pre.outputs.version) || github.ref }} + ref: ${{ needs.pre.outputs.increment != 'prerelease' && format('v{0}', needs.pre.outputs.version) || github.ref }} - run: | TARGET_DIR=./target/${{ matrix.target }} @@ -130,7 +140,7 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 - if: ${{ needs.pre.outputs.increment == 'release' }} + if: ${{ needs.pre.outputs.increment != 'prerelease' }} with: tag_name: v${{ needs.pre.outputs.version }} files: ${{ env.ASSET }} From 0928b279b7358a70e5a792b21feae89316a02690 Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:13:14 +0800 Subject: [PATCH 02/10] ci: remove local py script --- .github/workflows/ci.yml | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e75a9b..d2f4ac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,6 @@ jobs: runs-on: ubuntu-latest outputs: matrix: ${{ steps.matrix.outputs.matrix }} - version: ${{ steps.version.outputs.version }} increment: ${{ steps.increment.outputs.increment }} steps: - uses: actions/checkout@v3 @@ -35,11 +34,6 @@ jobs: - run: echo "matrix=$(jq -rc . .github/workflows/matrix.json)" >> $GITHUB_OUTPUT id: matrix - # Checks that the version on Cargo.toml matches the latest git - # tag, and sets the `version` variable to the next version. - - run: echo "version=$(ARG=next-${{ steps.increment.outputs.increment }} make py)" >> $GITHUB_OUTPUT - id: version - - name: Enumerate outputs run: | echo ${{ steps.increment.outputs.increment }} @@ -56,24 +50,25 @@ jobs: steps: - uses: actions/checkout@v3 - - # required for tests - - run: make ci-git-user - - name: Run tests - run: make test + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + make test - increment: - name: Increment ${{ needs.pre.outputs.increment }} version + inc: + name: Increment version needs: [pre, build-and-test] runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} steps: - uses: actions/checkout@v3 - uses: nguyenvukhang/semver-increment@v1 id: semver with: increment: ${{ matrix.increment }} - identifier: 'alpha' + identifier: "alpha" version-file: "Cargo.toml" version-regex: '^version = "(.*)"' @@ -90,8 +85,8 @@ jobs: # publish patch-level updates and above only publish-crates-io: name: Publish to Crates.io - if: needs.pre.outputs.increment != 'prerelease' - needs: [pre, increment] + if: needs.inc.outputs.increment != 'prerelease' + needs: [pre, inc] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -104,7 +99,7 @@ jobs: release-github: name: Release on GitHub - needs: [pre, increment] + needs: [pre, inc] runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -113,7 +108,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: ${{ needs.pre.outputs.increment != 'prerelease' && format('v{0}', needs.pre.outputs.version) || github.ref }} + ref: ${{ needs.inc.outputs.increment != 'prerelease' && format('v{0}', needs.pre.outputs.version) || github.ref }} - run: | TARGET_DIR=./target/${{ matrix.target }} @@ -140,7 +135,7 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 - if: ${{ needs.pre.outputs.increment != 'prerelease' }} + if: ${{ needs.inc.outputs.increment != 'prerelease' }} with: tag_name: v${{ needs.pre.outputs.version }} files: ${{ env.ASSET }} From 05a8618c8b625a2e2017fd2bf3fb63726a714045 Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:16:17 +0800 Subject: [PATCH 03/10] fix: increment read from pre --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2f4ac2..d34cbe6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,18 +67,19 @@ jobs: - uses: nguyenvukhang/semver-increment@v1 id: semver with: - increment: ${{ matrix.increment }} + increment: ${{ needs.pre.outputs.increment }} identifier: "alpha" version-file: "Cargo.toml" version-regex: '^version = "(.*)"' - name: Commit and tag for v${{ steps.semver.outputs.version }} run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + cargo build git add Cargo.toml Cargo.lock git commit -m 'ver: bump to ${{ steps.semver.outputs.version }}' - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' git tag v${{ steps.semver.outputs.version }} git push --tag From 1c2c181c96a62357b2a676325ebe7d5b18f3a0cd Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:30:31 +0800 Subject: [PATCH 04/10] ci: logic bugs --- .github/workflows/ci.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d34cbe6..7148671 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,9 +36,8 @@ jobs: - name: Enumerate outputs run: | - echo ${{ steps.increment.outputs.increment }} - echo ${{ steps.version.outputs.version }} - echo ${{ steps.matrix.outputs.matrix }} + echo 'increment: ${{ steps.increment.outputs.increment }}' + echo 'matrix: ${{ steps.version.outputs.version }}' build-and-test: name: Build & Test @@ -61,7 +60,7 @@ jobs: needs: [pre, build-and-test] runs-on: ubuntu-latest outputs: - version: ${{ steps.version.outputs.version }} + version: ${{ steps.semver.outputs.version }} steps: - uses: actions/checkout@v3 - uses: nguyenvukhang/semver-increment@v1 @@ -86,13 +85,13 @@ jobs: # publish patch-level updates and above only publish-crates-io: name: Publish to Crates.io - if: needs.inc.outputs.increment != 'prerelease' + if: needs.pre.outputs.increment != 'prerelease' needs: [pre, inc] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: - ref: v${{ needs.pre.outputs.version }} + ref: v${{ needs.inc.outputs.version }} - uses: katyo/publish-crates@v2 with: @@ -109,7 +108,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: ${{ needs.inc.outputs.increment != 'prerelease' && format('v{0}', needs.pre.outputs.version) || github.ref }} + ref: ${{ needs.pre.outputs.increment != 'prerelease' && format('v{0}', needs.inc.outputs.version) || github.ref }} - run: | TARGET_DIR=./target/${{ matrix.target }} @@ -128,7 +127,7 @@ jobs: - name: Build archive run: | - STAGING="git-nu-v${{ needs.pre.outputs.version }}-${{ matrix.target }}" + STAGING="git-nu-v${{ needs.inc.outputs.version }}-${{ matrix.target }}" mkdir -p "$STAGING" cp ${{ env.BINFILE }} "$STAGING" tar czf "$STAGING.tar.gz" "$STAGING" @@ -136,7 +135,7 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 - if: ${{ needs.inc.outputs.increment != 'prerelease' }} + if: ${{ needs.pre.outputs.increment != 'prerelease' }} with: - tag_name: v${{ needs.pre.outputs.version }} + tag_name: v${{ needs.inc.outputs.version }} files: ${{ env.ASSET }} From 8dcfd7ce2ceb371aca55854bf1b907812101a235 Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:37:14 +0800 Subject: [PATCH 05/10] ci: push back to HEAD that triggered action --- .github/workflows/ci.yml | 7 ++++++- Makefile | 7 ------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7148671..1767042 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: version-file: "Cargo.toml" version-regex: '^version = "(.*)"' - - name: Commit and tag for v${{ steps.semver.outputs.version }} + - name: Commit and push run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' @@ -79,6 +79,11 @@ jobs: cargo build git add Cargo.toml Cargo.lock git commit -m 'ver: bump to ${{ steps.semver.outputs.version }}' + git push + + - name: Tag and push + if: ${{ needs.pre.outputs.increment != 'prerelease' }} + run: | git tag v${{ steps.semver.outputs.version }} git push --tag diff --git a/Makefile b/Makefile index 359af60..269fd3f 100644 --- a/Makefile +++ b/Makefile @@ -35,13 +35,6 @@ load-bin: @cp $(GITNU_RELEASE_BIN) $(LOCAL_BIN) -# ──────────────────────────────────────────────────────────────────── -# MARK: - CI - -ci-git-user: - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - py: @$(PY_UTILS) $(ARG) From 8815f0268e84bc2beafa7a5c76bce15aaf7556ba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 6 Jul 2023 18:41:42 +0000 Subject: [PATCH 06/10] ver: bump to 0.7.2-alpha.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d584f6..f70ca58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "gitnu" -version = "0.7.1" +version = "0.7.2-alpha.0" dependencies = [ "atty", ] diff --git a/Cargo.toml b/Cargo.toml index e424e5f..480360f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitnu" -version = "0.7.1" +version = "0.7.2-alpha.0" authors = ["Nguyen Vu Khang "] description = """ gitnu indexes your git status so you can use numbers instead of filenames. From 66cf8ba6d56fff0d3c97b314e258c214682ec7cd Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:45:06 +0800 Subject: [PATCH 07/10] ci: remove last make --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1767042..772a018 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,8 @@ jobs: run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - make test + cargo build + cargo test --lib inc: name: Increment version @@ -121,7 +122,7 @@ jobs: echo "BINFILE=$TARGET_DIR/release/git-nu" >> $GITHUB_ENV - name: Build binary - run: make build + run: cargo build --release env: CARGO_BUILD_TARGET_DIR: ${{ env.TARGET_DIR }} From f4c64c810bcba20b9f541fe8c029047b9527c028 Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:46:20 +0800 Subject: [PATCH 08/10] chore: clean up makefile --- Makefile | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 269fd3f..1bdfb33 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ LOCAL_BIN=$(HOME)/dots/personal/.local/bin GITNU_RELEASE_BIN=$(PWD)/target/release/git-nu GITNU_DEBUG_BIN=$(PWD)/target/debug/git-nu -PY_UTILS := python3 scripts/utils.py ONE_TEST := 'tests::renames' current: @@ -13,29 +12,21 @@ install: make build make load-bin -dev: - cargo build - cargo test --lib - build: cargo build --bin git-nu --release @echo "Release build complete." test: cargo build - GITNU_DEBUG=0 cargo test --lib + cargo test --lib test-one: cargo build - GITNU_DEBUG=0 cargo test $(ONE_TEST) + cargo test $(ONE_TEST) # copies built binary to a path specified by $BIN load-bin: @rm -f $(LOCAL_BIN)/git-nu @cp $(GITNU_RELEASE_BIN) $(LOCAL_BIN) - -py: - @$(PY_UTILS) $(ARG) - -.PHONY: test load-bin +.PHONY: test test-one load-bin From a55bf9184789e1dc5b4520424c6771c2cdfb50b4 Mon Sep 17 00:00:00 2001 From: nguyenvukhang Date: Fri, 7 Jul 2023 02:46:34 +0800 Subject: [PATCH 09/10] chore: remove unused scripts --- scripts/get-git-commands.py | 13 -- scripts/utils.py | 306 ------------------------------------ 2 files changed, 319 deletions(-) delete mode 100644 scripts/get-git-commands.py delete mode 100644 scripts/utils.py diff --git a/scripts/get-git-commands.py b/scripts/get-git-commands.py deleted file mode 100644 index bf67c22..0000000 --- a/scripts/get-git-commands.py +++ /dev/null @@ -1,13 +0,0 @@ -import re, subprocess - - -def run_sh(*cmd): - return subprocess.check_output(cmd).decode("utf-8").split("\n") - - -output = run_sh("git", "--help", "--all") -NOT_WORD = re.compile("\W") - -for line in filter(lambda x: len(x) > 0 and NOT_WORD.match(x[0]), output): - command = line.strip().split(" ", 1)[0] - print(command) diff --git a/scripts/utils.py b/scripts/utils.py deleted file mode 100644 index 93b35e6..0000000 --- a/scripts/utils.py +++ /dev/null @@ -1,306 +0,0 @@ -import os -import subprocess -import re -import sys -from typing import Callable - -# Obtained from semver.org -# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string -# -# With an added v? in front to support an optional 'v' prefix. -SEMVER_REGEX_SRC = ( - "(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)" - + "(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))" - + "?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?" -) -SEMVER_REGEX = re.compile("^v?" + SEMVER_REGEX_SRC + "$") -CARGO_TOML_VERSION_REGEX = re.compile('^version = "(.*)"') - -DIR_PATH = os.path.dirname(os.path.realpath(__file__)) -PROJECT_ROOT = os.path.join(DIR_PATH, "..") - - -# fmt: off -# Cargo stuff -def cargo_toml_path(): return os.path.join(PROJECT_ROOT, "Cargo.toml") -def get_cargo_toml(): - with open(cargo_toml_path()) as f: lines = f.readlines() - return lines or [] -def set_cargo_toml(lines): - with open(cargo_toml_path(), "w") as f: f.writelines(lines) -# fmt: on - - -def run_sh(*cmd): - return subprocess.check_output(cmd).decode("utf-8").split("\n") - - -def get_semver_tags(): - all_tags = run_sh("git", "tag") - semver_tags = filter(SEMVER_REGEX.match, all_tags) - - def version_or_none(text): - try: - return Version.from_str(text) - except Exception: - return None - - versions = list(map(version_or_none, semver_tags)) - Version.sort(versions) - return versions - - -def split_trailing_number(text): - ptr = len(text) - for i in text[::-1]: - try: - int(i) - ptr -= 1 - except Exception: - break - return text[:ptr], int(text[ptr:]) - - -def assert_version_match(v_cargo, v_git_tag): - if not v_cargo == v_git_tag: - msg = "Cargo.toml version does not match latest git tag." - msg += "\n\tCargo.toml: %s" % v_cargo - msg += "\n\tGit tags : %s" % v_git_tag - print(msg) - sys.exit(1) - - -class Version: - def __init__( - s, major, minor, patch, pre - ): # type: (int, int, int, str|None) -> None - s.major, s.minor, s.patch, s.pre = major, minor, patch, pre - - # sort by prerelease with a rank list - @staticmethod - def sort(arr): # type: (list[Version]) -> None - PRERELEASE_RANKS = {"alpha": 1, "beta": 2, None: 3} - arr.sort(key=lambda v: v.pre_number()) - arr.sort(key=lambda v: PRERELEASE_RANKS.get(v.pre_name(), 0)) - - arr.sort(key=lambda v: v.patch) - arr.sort(key=lambda v: v.minor) - arr.sort(key=lambda v: v.major) - - @staticmethod - def from_str(text): - if text == None: - raise ValueError("Tried to init Version with None") - - match = SEMVER_REGEX.search(text) - if match == None: - raise ValueError('Invalid SemVer: "%s"' % (text)) - - # after passing the regex, the rest is safe: - major, minor, patch, pre = match.groups()[:4] - major, minor, patch = map(int, [major, minor, patch]) - return Version(major, minor, patch, pre) - - def __str__(self): - if self.pre is None: - return "%s.%s.%s" % (self.major, self.minor, self.patch) - return "%s.%s.%s-%s" % (self.major, self.minor, self.patch, self.pre) - - def __eq__(a, b): - return ( - a.major == b.major - and a.minor == b.minor - and a.patch == b.patch - and a.pre == b.pre - ) - - @staticmethod - def split_pre(text): - ptr = len(text) - for i in text[::-1]: - try: - int(i) - ptr -= 1 - except Exception: - break - return text[:ptr], int(text[ptr:]) - - def pre_name(self): - if self.pre == None: - return None - return Version.split_pre(self.pre)[0] - - def pre_number(self): - if self.pre == None: - return 0 - return Version.split_pre(self.pre)[1] - - # 1.2.3-alpha1 -> INVALID - # 1.2.3 -> 2.0.0-alpha1 - def next_major_pre(self): - if self.pre != None: - msg = "Unexpected existing pre. Use next_patch_pre() instead." - raise ValueError(msg) - self.next_minor_pre() - self.minor = 0 - self.major += 1 - return self - - # 1.2.3-alpha1 -> INVALID - # 1.2.3 -> 1.3.0-alpha1 - def next_minor_pre(self): - if self.pre != None: - msg = "Unexpected existing pre. Use next_patch_pre() instead." - raise ValueError(msg) - self.next_patch_pre() - self.patch = 0 - self.minor += 1 - return self - - # 1.2.3-alpha1 -> 1.2.3-alpha2 - # 1.2.3 -> 1.2.4-alpha1 - def next_patch_pre(self): - if self.pre == None: - self.patch += 1 - self.pre = "alpha1" - else: - text, num = Version.split_pre(self.pre) - self.pre = "%s%d" % (text, num + 1) - return self - - def release(self): - self.pre = None - return self - - @staticmethod - def from_toml(toml_lines): - regexed = list(map(lambda x: CARGO_TOML_VERSION_REGEX.match(x), toml_lines)) - - try: # throws an error if no regex matches are found - index = next(i for i, v in enumerate(regexed) if v is not None) - except StopIteration: - raise ValueError("Version attribute not found in Cargo.toml") - - match = list(filter(bool, regexed))[0] - version_text = match.groups()[0] - return Version.from_str(version_text), index - - @staticmethod - def from_latest_tag(): - return get_semver_tags()[-1] - - def tag(self): - return "v" + str(self) - - def is_release(self): - return self.pre is None - - -def current_version(): - cargo_toml = get_cargo_toml() - - # get latest version - v_cargo, _ = Version.from_toml(cargo_toml) - # v_git_tag = Version.from_latest_tag() - - # assert match - # assert_version_match(v_cargo, v_git_tag) - - return v_cargo - - -def increment(inc_fn): # type: (Callable[[Version], Version]) -> None - cargo_toml = get_cargo_toml() - - # get latest version - v_cargo, version_line_index = Version.from_toml(cargo_toml) - v_git_tag = Version.from_latest_tag() - - # assert match - # assert_version_match(v_cargo, v_git_tag) - print(v_cargo) - print(v_git_tag) - - print("Current version: %s" % (v_cargo)) - - # increment - v_next = inc_fn(v_cargo) - - print("Next pre: %s" % (v_next)) - - Git.update_and_commit(cargo_toml, version_line_index, v_next) - if v_next.is_release(): - Git.tag(v_next) - Git.push() - - -class Git: - def update_and_commit( - cargo_toml, line_num, ver - ): # type: (list[str], int, Version) -> None - # change the line in Cargo.toml - cargo_toml[line_num] = 'version = "%s"\n' % (ver) - - set_cargo_toml(cargo_toml) - - # build to update_and_commit Cargo.lock - subprocess.run(["cargo", "build"]) - - subprocess.run(["git", "add", "Cargo.toml", "Cargo.lock"]) - subprocess.run(["git", "commit", "-m", "ver: bump to %s" % ver.tag()]) - - def tag(ver): # type: (Version) -> None - subprocess.run(["git", "tag", ver.tag()]) - subprocess.run(["git", "push", "--tags"]) - - def push(): - subprocess.run(["git", "push"]) - - -class App: - # fmt: off - def increment_major_pre(): increment(lambda x: x.next_major_pre()) - def increment_minor_pre(): increment(lambda x: x.next_minor_pre()) - def increment_patch_pre(): increment(lambda x: x.next_patch_pre()) - def increment_release(): increment(lambda x: x.release()) - - def next_patch_pre(): print(current_version().next_patch_pre()) - def next_minor_pre(): print(current_version().next_minor_pre()) - def next_major_pre(): print(current_version().next_minor_pre()) - def next_release(): print(current_version().release()) - - def current_version(): print(current_version()) - def latest_tag(): print(Version.from_latest_tag()) - # fmt: on - - -def main(): - if len(sys.argv) == 0: - return - - app = {} - - app["increment-major-pre"] = App.increment_major_pre - app["increment-minor-pre"] = App.increment_minor_pre - app["increment-patch-pre"] = App.increment_patch_pre - app["increment-release"] = App.increment_release - - app["next-major-pre"] = App.next_major_pre - app["next-minor-pre"] = App.next_minor_pre - app["next-patch-pre"] = App.next_patch_pre - app["next-release"] = App.next_release - - app["current-version"] = App.current_version - app["latest-tag"] = App.latest_tag - - run = lambda: () - try: - run = app[sys.argv[1]] - except KeyError: - print("Invalid key. Please refer to %s" % (__file__)) - - run() - - -if __name__ == "__main__": - main() From 6fe00715710f57f5e44fcba6a582842c25b08843 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 6 Jul 2023 18:48:03 +0000 Subject: [PATCH 10/10] ver: bump to 0.7.2-alpha.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f70ca58..8ad8236 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "gitnu" -version = "0.7.2-alpha.0" +version = "0.7.2-alpha.1" dependencies = [ "atty", ] diff --git a/Cargo.toml b/Cargo.toml index 480360f..6ca5cd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitnu" -version = "0.7.2-alpha.0" +version = "0.7.2-alpha.1" authors = ["Nguyen Vu Khang "] description = """ gitnu indexes your git status so you can use numbers instead of filenames.