Skip to content

Commit

Permalink
fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
theopfr committed Feb 16, 2025
1 parent 479343f commit 6c05686
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def validate_semver_bump(previous_version: str, next_version: str) -> BumpType:
if previous_version == next_version:
raise ValueError("Version has to be bumped!")

print(f"Comparing next version {next_version} with previous version {previous_version}.")

previous_version = list(map(int, previous_version.split(".")))
next_version = list(map(int, next_version.split(".")))

Expand All @@ -36,6 +38,7 @@ def validate_semver_bump(previous_version: str, next_version: str) -> BumpType:
lower_levels_reset = all(next_version[jdx] == 0 for jdx in range(idx + 1, len(semver_parts)))

if correct_bump and lower_levels_reset:
print(f"{semver_parts[idx].value} version bump.")
return semver_parts[idx]

raise_semver_exception()
Expand Down
33 changes: 12 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,35 @@ jobs:
version-check:
needs: test
if: github.event.pull_request.base.ref == 'main'
if: github.event_name == 'pull_request' || github.event_name == 'push'
runs-on: ubuntu-latest

outputs:
bump_type: ${{ steps.check_version.outputs.bump_type }}

steps:
- name: Get previous version
id: previous_version
- name: Checkout repository
uses: actions/checkout@v2

- name: Get new version
id: new_version
run: echo ::set-output name=version::$(cat VERSION)

- name: Get current version
id: current_version
- name: Get previous version
id: previous_version
run: echo ::set-output name=version::$(curl https://raw.githubusercontent.com/${{ github.repository }}/main/VERSION)

- name: Check version
id: check_version
run: |
python check_version.py ${{ steps.previous_version.outputs.version }} ${{ steps.current_version.outputs.version }}
python .github/version_check.py ${{ steps.previous_version.outputs.version }} ${{ steps.new_version.outputs.version }}
image-release:
needs: version-check
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.version-check.outputs.bump_type != 'patch'
if: github.event_name == 'push' && github.ref == 'main' && needs.version-check.outputs.bump_type != 'patch'
runs-on: ubuntu-latest

steps:
- name: Get previous version
id: previous_version
run: echo ::set-output name=version::$(cat VERSION)

- name: Get current version
id: current_version
run: echo ::set-output name=version::$(cat VERSION)

- name: Check version
run: |
python check_version.py ${{ steps.previous_version.outputs.version }} ${{ steps.current_version.outputs.version }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
Expand All @@ -116,8 +107,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.current_version.outputs.version }}
release_name: 🎉 N2E Backend ${{ steps.current_version.outputs.version }}
tag_name: v${{ needs.version-check.outputs.bump_type }}
release_name: 🎉 N2E Backend ${{ needs.version-check.outputs.bump_type }}
draft: false
prerelease: false
id: create_release
Expand Down

0 comments on commit 6c05686

Please sign in to comment.