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

feat(ci): check if version was bumped #1899

Merged
merged 1 commit into from
Jul 12, 2023
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
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)