Skip to content

Commit

Permalink
check if version was bumped
Browse files Browse the repository at this point in the history
Signed-off-by: ozkanonur <[email protected]>
  • Loading branch information
onur-ozkan committed Jul 7, 2023
1 parent 6096138 commit 2061c81
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/validate-mm2-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Validate mm2 version

on:
pull_request:
branches:
- main

jobs:
validate_version_change:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3

- name: Install dependencies
run: pip install toml

- name: Run version check
run: ./scripts/ci/validate-version-bump.py
35 changes: 35 additions & 0 deletions scripts/ci/validate-version-bump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

import subprocess
import sys
import toml


def get_previous_version():
subprocess.run(['git', 'fetch', 'origin', 'main'])
previous_version = subprocess.check_output(
['git', 'show', 'origin/main:./mm2src/mm2_bin_lib/Cargo.toml']).decode()
cargo_data = toml.loads(previous_version)
previous_version = cargo_data['package']['version']

return previous_version


def get_current_version():
with open('./mm2src/mm2_bin_lib/Cargo.toml', 'r') as file:
cargo_toml_pr = file.read()

cargo_data_pr = toml.loads(cargo_toml_pr)

return cargo_data_pr['package']['version']


current_version = get_current_version()
previous_version = get_previous_version()

print(f"Main branch mm2 version: {previous_version}")
print(f"Current branch mm2 version: {current_version}")

if previous_version == current_version:
print("Bump the mm2 version before merge!")
sys.exit(1)

0 comments on commit 2061c81

Please sign in to comment.