From febbf86c7c3b6b99b56bb6bceae1e48e6eb5acca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Est=C3=ADbaliz=20Parcero?= <5576714+esparig@users.noreply.github.com> Date: Tue, 29 Jul 2025 10:40:10 +0200 Subject: [PATCH 1/4] Update release.yaml --- .github/workflows/release.yaml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9d4cd92..7d852b5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Releases workflow +name: Release workflow - Increase Version on: release: @@ -81,24 +81,26 @@ jobs: echo "__version__ = '$new_version'" > oscar_python/version.py env: new_version: ${{ steps.get_version.outputs.new_version }} - - - name: Commit version change + + - name: Commit version change and push to a new branch if: env.changes_detected == 'true' run: | git config --global user.name 'github-actions' git config --global user.email 'github-actions@github.com' + git checkout -b bump-version-${{ steps.get_version.outputs.new_version }} git add oscar_python/version.py git commit -m "Bump version to $new_version" - git push + git push origin bump-version-${{ steps.get_version.outputs.new_version }} env: new_version: ${{ steps.get_version.outputs.new_version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build package + - name: Create Pull Request if: env.changes_detected == 'true' - run: | - python setup.py sdist bdist_wheel - - - name: Publish package to PyPI - if: env.changes_detected == 'true' - uses: pypa/gh-action-pypi-publish@release/v1 + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: bump-version-${{ steps.get_version.outputs.new_version }} + title: "Bump version to ${{ steps.get_version.outputs.new_version }}" + body: "Automated version bump and release workflow" + base: main From fc10bbf926b2d3f86584657245ec15523e750442 Mon Sep 17 00:00:00 2001 From: esparig <5576714+esparig@users.noreply.github.com> Date: Tue, 29 Jul 2025 10:51:21 +0200 Subject: [PATCH 2/4] Modified release workflows to comply with PR policy --- .github/workflows/release-build.yaml | 33 ++++++++ .github/workflows/release-version.yaml | 106 +++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 .github/workflows/release-build.yaml create mode 100644 .github/workflows/release-version.yaml diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml new file mode 100644 index 0000000..3e0d298 --- /dev/null +++ b/.github/workflows/release-build.yaml @@ -0,0 +1,33 @@ +name: Release workflow - Build and Publish Package + +on: + push: + branches: + - main + paths: + - 'oscar_python/version.py' # Only run when the version is bumped + +jobs: + build-and-publish: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools wheel twine + + - name: Build package + run: | + python setup.py sdist bdist_wheel + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release-version.yaml b/.github/workflows/release-version.yaml new file mode 100644 index 0000000..d507ce3 --- /dev/null +++ b/.github/workflows/release-version.yaml @@ -0,0 +1,106 @@ +name: Release workflow - Increase Version + +on: + release: + types: [created] + schedule: + - cron: '0 0 1 * *' # Runs at 00:00 on the 1st of every month + workflow_dispatch: + inputs: + version_type: + description: 'Type of version increment (patch, minor, major)' + required: true + default: 'patch' + +jobs: + release: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools wheel twine + + - name: Check for changes inside oscar_python directory + id: check_changes + run: | + PREV_MONTH=$(date -d "last month" +%Y-%m) + if git log --since="$PREV_MONTH-01" --until="$(date +%Y-%m-01)" --pretty=format: --name-only | grep -q '^oscar_python/'; then + echo "changes_detected=true" >> $GITHUB_ENV + else + echo "changes_detected=false" >> $GITHUB_ENV + fi + + - name: Get current version + if: env.changes_detected == 'true' + id: get_version + run: | + current_version=$(python setup.py --version) + echo "Current version: $current_version" + IFS='.' read -r -a version_parts <<< "$current_version" + major=${version_parts[0]} + minor=${version_parts[1]} + patch=${version_parts[2]} + version_type="${{ github.event.inputs.version_type }}" + if [ "$version_type" == "major" ]; then + new_major=$((major + 1)) + new_version="$new_major.0.0" + elif [ "$version_type" == "minor" ]; then + new_minor=$((minor + 1)) + new_version="$major.$new_minor.0" + else + new_patch=$((patch + 1)) + new_version="$major.$minor.$new_patch" + fi + echo "New version: $new_version" + echo "::set-output name=new_version::$new_version" + + - name: Create GitHub Release + if: env.changes_detected == 'true' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.get_version.outputs.new_version }} + release_name: Release ${{ steps.get_version.outputs.new_version }} + draft: false + prerelease: false + + - name: Update version.py + if: env.changes_detected == 'true' + run: | + echo "__version__ = '$new_version'" > oscar_python/version.py + env: + new_version: ${{ steps.get_version.outputs.new_version }} + + - name: Commit version change and push to a new branch + if: env.changes_detected == 'true' + run: | + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@github.com' + git checkout -b bump-version-${{ steps.get_version.outputs.new_version }} + git add oscar_python/version.py + git commit -m "Bump version to $new_version" + git push origin bump-version-${{ steps.get_version.outputs.new_version }} + env: + new_version: ${{ steps.get_version.outputs.new_version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Pull Request + if: env.changes_detected == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: bump-version-${{ steps.get_version.outputs.new_version }} + title: "Bump version to ${{ steps.get_version.outputs.new_version }}" + body: "Automated version bump and release workflow" + base: main From 763e7eef20d2d196fdca136e9efd461c5772b5fa Mon Sep 17 00:00:00 2001 From: esparig <5576714+esparig@users.noreply.github.com> Date: Tue, 29 Jul 2025 11:05:22 +0200 Subject: [PATCH 3/4] Removing old release --- .github/workflows/release.yaml | 106 --------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 7d852b5..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,106 +0,0 @@ -name: Release workflow - Increase Version - -on: - release: - types: [created] - schedule: - - cron: '0 0 1 * *' # Runs at 00:00 on the 1st of every month - workflow_dispatch: - inputs: - version_type: - description: 'Type of version increment (patch, minor, major)' - required: true - default: 'patch' - -jobs: - release: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.12' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install setuptools wheel twine - - - name: Check for changes inside oscar_python directory - id: check_changes - run: | - PREV_MONTH=$(date -d "last month" +%Y-%m) - if git log --since="$PREV_MONTH-01" --until="$(date +%Y-%m-01)" --pretty=format: --name-only | grep -q '^oscar_python/'; then - echo "changes_detected=true" >> $GITHUB_ENV - else - echo "changes_detected=false" >> $GITHUB_ENV - fi - - - name: Get current version - if: env.changes_detected == 'true' - id: get_version - run: | - current_version=$(python setup.py --version) - echo "Current version: $current_version" - IFS='.' read -r -a version_parts <<< "$current_version" - major=${version_parts[0]} - minor=${version_parts[1]} - patch=${version_parts[2]} - version_type="${{ github.event.inputs.version_type }}" - if [ "$version_type" == "major" ]; then - new_major=$((major + 1)) - new_version="$new_major.0.0" - elif [ "$version_type" == "minor" ]; then - new_minor=$((minor + 1)) - new_version="$major.$new_minor.0" - else - new_patch=$((patch + 1)) - new_version="$major.$minor.$new_patch" - fi - echo "New version: $new_version" - echo "::set-output name=new_version::$new_version" - - - name: Create GitHub Release - if: env.changes_detected == 'true' - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ steps.get_version.outputs.new_version }} - release_name: Release ${{ steps.get_version.outputs.new_version }} - draft: false - prerelease: false - - - name: Update version.py - if: env.changes_detected == 'true' - run: | - echo "__version__ = '$new_version'" > oscar_python/version.py - env: - new_version: ${{ steps.get_version.outputs.new_version }} - - - name: Commit version change and push to a new branch - if: env.changes_detected == 'true' - run: | - git config --global user.name 'github-actions' - git config --global user.email 'github-actions@github.com' - git checkout -b bump-version-${{ steps.get_version.outputs.new_version }} - git add oscar_python/version.py - git commit -m "Bump version to $new_version" - git push origin bump-version-${{ steps.get_version.outputs.new_version }} - env: - new_version: ${{ steps.get_version.outputs.new_version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Pull Request - if: env.changes_detected == 'true' - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: bump-version-${{ steps.get_version.outputs.new_version }} - title: "Bump version to ${{ steps.get_version.outputs.new_version }}" - body: "Automated version bump and release workflow" - base: main From aa0504fc19ae57cdc92c46512942fd90b1391511 Mon Sep 17 00:00:00 2001 From: esparig <5576714+esparig@users.noreply.github.com> Date: Tue, 29 Jul 2025 12:10:08 +0200 Subject: [PATCH 4/4] Modified release-version workflow to check changes from last release --- .github/workflows/release-version.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-version.yaml b/.github/workflows/release-version.yaml index d507ce3..8f865e3 100644 --- a/.github/workflows/release-version.yaml +++ b/.github/workflows/release-version.yaml @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for tags - name: Set up Python uses: actions/setup-python@v4 @@ -33,11 +35,22 @@ jobs: - name: Check for changes inside oscar_python directory id: check_changes run: | - PREV_MONTH=$(date -d "last month" +%Y-%m) - if git log --since="$PREV_MONTH-01" --until="$(date +%Y-%m-01)" --pretty=format: --name-only | grep -q '^oscar_python/'; then + # Get the latest release tag + latest_release=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -z "$latest_release" ]; then + echo "No previous release found - treating as first release" echo "changes_detected=true" >> $GITHUB_ENV else - echo "changes_detected=false" >> $GITHUB_ENV + echo "Latest release: $latest_release" + # Check if there are changes in oscar_python directory since last release + if git log $latest_release..HEAD --pretty=format: --name-only | grep -q '^oscar_python/'; then + echo "Changes detected in oscar_python directory since $latest_release" + echo "changes_detected=true" >> $GITHUB_ENV + else + echo "No changes detected in oscar_python directory since $latest_release" + echo "changes_detected=false" >> $GITHUB_ENV + fi fi - name: Get current version