forked from jl777/SuperNET
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ozkanonur <[email protected]>
- Loading branch information
1 parent
6096138
commit c1d281a
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-dev-to-main-pr.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |