Skip to content

Commit

Permalink
Add scripts/release.py
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed Jun 28, 2024
1 parent 0462177 commit 1cace28
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ jobs:
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: "NocoDB Mobile (Unofficial prototype) v${{ github.ref }}"
files: "build/app/outputs/flutter-apk/app-release.apk"
prerelease: ${{ contains(github.ref, 'dev') }}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
release:
python3 scripts/release.py

run_integration_test rit:
flutter run --dart-define-from-file=integration_test/.env -t integration_test/hello_test.dart

Expand Down
47 changes: 47 additions & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from datetime import datetime
import subprocess

DRY_RUN = False

def run(command: str) -> str:
return subprocess.run(
command,
shell=True,
capture_output=True,
text=True
).stdout.strip()

def version_up(latest_tag):
parts = latest_tag.split('.')

latest_yymm = f"{parts[0]}.{parts[1]}"
current_yymm = datetime.now().strftime("%y.%m")

if latest_yymm == current_yymm:
if len(parts) == 3:
new_minor = int(parts[2]) + 1
else:
new_minor = 1
return f"{current_yymm}.{new_minor}"
else:
return current_yymm

# print(version_up("23.02")) # 24.06
# print(version_up("23.02.5")) # 24.06
# print(version_up("24.06")) # 24.06.1
# print(version_up("24.06.1")) # 24.06.2

now = datetime.now()
YYMM = now.strftime("%y.%m")

latest_tag = run("gh release list --json tagName --jq '.[0] | .tagName'")
print(f'latest tag: {latest_tag}')

new_tag = version_up(latest_tag)
print(f'new tag: {new_tag}')

push_command = f"git tag {new_tag} && git push origin main {new_tag}"
if not DRY_RUN:
run(push_command)
else:
print(push_command)

0 comments on commit 1cace28

Please sign in to comment.