diff --git a/.github/workflows/check_versions.py b/.github/workflows/check_versions.py new file mode 100644 index 00000000..cd4e950d --- /dev/null +++ b/.github/workflows/check_versions.py @@ -0,0 +1,58 @@ +# !/usr/bin/env python3 +import yaml +import semver +import subprocess + +# Define the file paths +files = ['client.yml', 'management.yml', 'source/client.yml', 'source/management.yml'] + + +# Function to extract version from YAML +def extract_version(file_path): + with open(file_path, 'r') as f: + content = yaml.safe_load(f) + return content.get('info', {}).get('version') + + +# Extract versions from all files +versions = [extract_version(file) for file in files] + +# Check if all versions are the same +if len(set(versions)) != 1: + raise ValueError(f"Versions do not match across files: {versions}: please make sure all files {files} have the same version") + +# Get the current version +current_version = versions[0] + +# Check that current version is a valid semver +if not semver.VersionInfo.is_valid(current_version): + raise ValueError(f"Current version '{current_version}' is not a valid semver.") + +# Parse current version +current_version_info = semver.VersionInfo.parse(current_version) + +# Get the latest git tag +result = subprocess.run(['git', 'describe', '--tags', '--abbrev=0', 'origin/main'], capture_output=True, text=True) +latest_tag = result.stdout.strip() +print(f"Latest tag: {latest_tag}") +latest_tag = latest_tag.lstrip('v') +print(f"Latest tag stripped of leading v: {latest_tag}") +# Parse the latest tag as a semver +if not semver.VersionInfo.is_valid(latest_tag): + raise ValueError(f"Latest git tag '{latest_tag}' is not a valid semver.") + +latest_version_info = semver.VersionInfo.parse(latest_tag) + +# Calculate possible next versions +next_patch_version = str(latest_version_info.bump_patch()) +next_minor_version = str(latest_version_info.bump_minor()) +next_major_version = str(latest_version_info.bump_major()) + +# Check if the current version matches one of the expected next versions +if current_version not in [next_patch_version, next_minor_version, next_major_version]: + raise ValueError( + f"Current version '{current_version}' does not match the next expected versions: " + f"patch '{next_patch_version}', minor '{next_minor_version}', or major '{next_major_version}'." + ) + +print(f"All versions match and are valid. Current version '{current_version}' matches one of the next possible versions.") \ No newline at end of file diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml new file mode 100644 index 00000000..ce723a7d --- /dev/null +++ b/.github/workflows/version-check.yml @@ -0,0 +1,30 @@ +name: Check Version Consistency and Git Tag Match + +on: + pull_request: + branches: + - main + +jobs: + check-versions: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Fetch all tags + run: git fetch --tags + + - name: List latest tag + run: git describe --tags --abbrev=0 origin/main + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' # specify the Python version you want to use + + - name: Install dependencies + run: pip install pyyaml semver + + - name: Parse and check versions + run: python .github/workflows/check_versions.py \ No newline at end of file diff --git a/client.yml b/client.yml index 8f1185ca..374d41bd 100644 --- a/client.yml +++ b/client.yml @@ -15,7 +15,7 @@ info: license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html - version: 0.26.28 + version: 0.26.30 host: demo.ziti.dev basePath: /edge/client/v1 paths: diff --git a/go.mod b/go.mod index 5de05240..4cb7cb82 100644 --- a/go.mod +++ b/go.mod @@ -38,6 +38,6 @@ require ( go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/trace v1.29.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.24.0 // indirect + golang.org/x/sys v0.25.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 9c62c7cc..152b74a1 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/management.yml b/management.yml index 9641a7fc..d595bd17 100644 --- a/management.yml +++ b/management.yml @@ -15,7 +15,7 @@ info: license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html - version: 0.26.28 + version: 0.26.30 host: demo.ziti.dev basePath: /edge/management/v1 paths: diff --git a/rest_client_api_server/doc.go b/rest_client_api_server/doc.go index 4c5ecd5a..0900ae3c 100644 --- a/rest_client_api_server/doc.go +++ b/rest_client_api_server/doc.go @@ -30,7 +30,7 @@ // https // Host: demo.ziti.dev // BasePath: /edge/client/v1 -// Version: 0.26.28 +// Version: 0.26.30 // License: Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0.html // Contact: OpenZiti https://openziti.discourse.group // diff --git a/rest_client_api_server/embedded_spec.go b/rest_client_api_server/embedded_spec.go index 6f3d42ba..188871fe 100644 --- a/rest_client_api_server/embedded_spec.go +++ b/rest_client_api_server/embedded_spec.go @@ -64,7 +64,7 @@ func init() { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "version": "0.26.28" + "version": "0.26.30" }, "host": "demo.ziti.dev", "basePath": "/edge/client/v1", @@ -7672,7 +7672,7 @@ func init() { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "version": "0.26.28" + "version": "0.26.30" }, "host": "demo.ziti.dev", "basePath": "/edge/client/v1", diff --git a/rest_management_api_server/doc.go b/rest_management_api_server/doc.go index 737465c8..e2278eda 100644 --- a/rest_management_api_server/doc.go +++ b/rest_management_api_server/doc.go @@ -30,7 +30,7 @@ // https // Host: demo.ziti.dev // BasePath: /edge/management/v1 -// Version: 0.26.28 +// Version: 0.26.30 // License: Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0.html // Contact: OpenZiti https://openziti.discourse.group // diff --git a/rest_management_api_server/embedded_spec.go b/rest_management_api_server/embedded_spec.go index 992fbd6e..925e056d 100644 --- a/rest_management_api_server/embedded_spec.go +++ b/rest_management_api_server/embedded_spec.go @@ -64,7 +64,7 @@ func init() { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "version": "0.26.28" + "version": "0.26.30" }, "host": "demo.ziti.dev", "basePath": "/edge/management/v1", @@ -28517,7 +28517,7 @@ func init() { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "version": "0.26.28" + "version": "0.26.30" }, "host": "demo.ziti.dev", "basePath": "/edge/management/v1", diff --git a/source/client.yml b/source/client.yml index 84f7b0a0..dff6b416 100644 --- a/source/client.yml +++ b/source/client.yml @@ -1,7 +1,7 @@ --- swagger: '2.0' info: - version: 0.26.28 + version: 0.26.30 title: Ziti Edge Client description: OpenZiti Edge Client API contact: diff --git a/source/management.yml b/source/management.yml index 695fce35..6053e523 100644 --- a/source/management.yml +++ b/source/management.yml @@ -1,7 +1,7 @@ --- swagger: '2.0' info: - version: 0.26.28 + version: 0.26.30 title: Ziti Edge Management description: OpenZiti Edge Management API contact: