From ad3019fcdcdfb63418c4dd96352e63498d0b5d33 Mon Sep 17 00:00:00 2001 From: rihi <19492038+rihi@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:45:09 +0100 Subject: [PATCH 1/2] Fix automatic release Changes automatic release to not push release commits to any branch. Instead, the commit is simply tagged and only the tag is pushed. This results in the tags to not be included in any branch. --- .github/workflows/release.yml | 12 ++++++------ plugin.json | 1 - update_for_release.py | 21 ++++++++++++++------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7927d067..70cd69b04 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,9 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true - name: Set git user uses: fregante/setup-git-user@v2 @@ -25,15 +28,12 @@ jobs: id: update run: echo "version=$(python update_for_release.py)" >> "$GITHUB_OUTPUT" # returns new version to output - - name: Commit changes + - name: Commit changes & push run: | git add plugin.json git commit -m "Update for release ${{ steps.update.outputs.version }}" - - - name: Push changes and tags - run: | - git push origin HEAD - git push origin --tags + git tag "v${{ steps.update.outputs.version }}" + git push origin v${{ steps.update.outputs.version }} - name: Create release uses: softprops/action-gh-release@v1 diff --git a/plugin.json b/plugin.json index b8429b796..d415733a9 100644 --- a/plugin.json +++ b/plugin.json @@ -27,7 +27,6 @@ ], "other": [] }, - "version": "0.2.0", "author": "fkie-cad", "minimumbinaryninjaversion": 4271 } diff --git a/update_for_release.py b/update_for_release.py index 766f6590f..fc22c9280 100644 --- a/update_for_release.py +++ b/update_for_release.py @@ -1,19 +1,26 @@ import json +import subprocess import time from pathlib import Path -if __name__ == "__main__": - release_path = Path("plugin.json") - with release_path.open("r") as file: - data = json.load(file) - old_version: str = data["version"] +def get_patch(line: str) -> int: + return int(line[index + 1 :]) if (index := line.rfind(".")) != -1 else 0 + + +if __name__ == "__main__": new_version = time.strftime("%Y-%m-%d") - if old_version.startswith(new_version): - patch = int(old_version[index + 1 :]) if (index := old_version.rfind(".")) != -1 else 0 + process = subprocess.run(["git", "tag", "-l", f"v{new_version}*"], text=True, capture_output=True) + patch = max((get_patch(line) for line in process.stdout.splitlines()), default=None) + + if patch is not None: new_version += f".{patch + 1}" + release_path = Path("plugin.json") + with release_path.open("r") as file: + data = json.load(file) + data["version"] = new_version with release_path.open("w") as file: From 1814957b6c0d378eae6844ecb3c0315ea6dd7bc5 Mon Sep 17 00:00:00 2001 From: rihi <19492038+rihi@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:45:18 +0100 Subject: [PATCH 2/2] Add comment --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70cd69b04..7cf969946 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: + with: # https://github.com/actions/checkout/issues/1471 fetch-depth: 0 fetch-tags: true