Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change automatic release to not push to main #395

Merged
merged 2 commits into from
Mar 7, 2024
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with: # https://github.com/actions/checkout/issues/1471
fetch-depth: 0
fetch-tags: true

- name: Set git user
uses: fregante/setup-git-user@v2
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
],
"other": []
},
"version": "0.2.0",
"author": "fkie-cad",
"minimumbinaryninjaversion": 4271
}
21 changes: 14 additions & 7 deletions update_for_release.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading