From a8af68467453b296150f1743dfd4029966912a60 Mon Sep 17 00:00:00 2001 From: umberto di fabrizio Date: Tue, 25 Feb 2025 17:13:18 +0100 Subject: [PATCH 1/4] Added automatic version bump flow --- .github/workflows/version_bump.yml | 100 +++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/version_bump.yml diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml new file mode 100644 index 000000000..918d50840 --- /dev/null +++ b/.github/workflows/version_bump.yml @@ -0,0 +1,100 @@ +name: Version Bump +run-name: Version bump ${{ inputs.bump_type }}${{ inputs.test_mode && ' (TEST)' || '' }} + +on: + workflow_dispatch: + inputs: + bump_type: + description: "Version bump type" + required: true + default: "patch" + type: choice + options: + - patch + - minor + - major + test_mode: + description: "Run in test mode (publishes to Test PyPI)" + required: true + default: false + type: boolean + +permissions: + contents: write + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@v2.10.4 + with: + egress-policy: audit + + - uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5.4.0 + with: + python-version: "3.9" + + - name: Setup Poetry + uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 + with: + poetry-version: "1.3.1" + + - name: Configure Git + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + + - name: Bump version + run: | + if [[ "${{ inputs.test_mode }}" == "true" ]]; then + TIMESTAMP=$(date +%Y%m%d%H%M%S) + TEST_VERSION="0.0.0-test.${TIMESTAMP}" + poetry version ${TEST_VERSION} + echo "NEW_VERSION=${TEST_VERSION}" >> $GITHUB_ENV + echo "TAG_PREFIX=test-" >> $GITHUB_ENV + echo "BRANCH_NAME=test/version-bump" >> $GITHUB_ENV + else + CURRENT_VERSION=$(poetry version -s) + poetry version ${{ inputs.bump_type }} + NEW_VERSION=$(poetry version -s) + echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV + echo "TAG_PREFIX=v" >> $GITHUB_ENV + echo "BRANCH_NAME=master" >> $GITHUB_ENV + fi + + - name: Commit and push changes + run: | + git add pyproject.toml + git commit -m "Version bump to ${TAG_PREFIX}${NEW_VERSION}" + if [[ "${{ inputs.test_mode }}" == "true" ]]; then + git checkout -b ${BRANCH_NAME} + fi + git push origin HEAD:${BRANCH_NAME} + + - name: Create and push tag + run: | + git tag -a "${TAG_PREFIX}${NEW_VERSION}" -m "Release version ${NEW_VERSION}" + git push origin "${TAG_PREFIX}${NEW_VERSION}" + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.TAG_PREFIX }}${{ env.NEW_VERSION }} + name: ${{ env.TAG_PREFIX }}${{ env.NEW_VERSION }} + generate_release_notes: true + draft: false + prerelease: ${{ inputs.test_mode }} + + - name: Notify Slack + uses: ./.github/workflows/JOB_slack_message.yml + with: + icon: ":arrows_counterclockwise:" + message: | + ${{ inputs.test_mode && '[TEST] ' || '' }}Version ${{ env.TAG_PREFIX }}${{ env.NEW_VERSION }} has been bumped and tagged + Type: ${{ inputs.bump_type }} From fde54bec1fdef10790cbba1dfc105941857c9a8c Mon Sep 17 00:00:00 2001 From: umberto di fabrizio Date: Tue, 25 Feb 2025 17:25:19 +0100 Subject: [PATCH 2/4] Cleaned up flow --- .github/workflows/version_bump.yml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 918d50840..6b96d0f99 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -40,11 +40,6 @@ jobs: with: python-version: "3.9" - - name: Setup Poetry - uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 - with: - poetry-version: "1.3.1" - - name: Configure Git run: | git config user.name github-actions[bot] @@ -54,15 +49,12 @@ jobs: run: | if [[ "${{ inputs.test_mode }}" == "true" ]]; then TIMESTAMP=$(date +%Y%m%d%H%M%S) - TEST_VERSION="0.0.0-test.${TIMESTAMP}" - poetry version ${TEST_VERSION} - echo "NEW_VERSION=${TEST_VERSION}" >> $GITHUB_ENV + echo "NEW_VERSION=0.0.0-test.${TIMESTAMP}" >> $GITHUB_ENV echo "TAG_PREFIX=test-" >> $GITHUB_ENV echo "BRANCH_NAME=test/version-bump" >> $GITHUB_ENV else - CURRENT_VERSION=$(poetry version -s) - poetry version ${{ inputs.bump_type }} - NEW_VERSION=$(poetry version -s) + python deploy/increase_version.py --${{ inputs.bump_type }} + NEW_VERSION=$(cat .version) echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV echo "TAG_PREFIX=v" >> $GITHUB_ENV echo "BRANCH_NAME=master" >> $GITHUB_ENV @@ -70,8 +62,8 @@ jobs: - name: Commit and push changes run: | - git add pyproject.toml - git commit -m "Version bump to ${TAG_PREFIX}${NEW_VERSION}" + git add pyproject.toml darwin/__init__.py + git commit -m "Version bump to ${{ env.NEW_VERSION }}" if [[ "${{ inputs.test_mode }}" == "true" ]]; then git checkout -b ${BRANCH_NAME} fi @@ -79,7 +71,7 @@ jobs: - name: Create and push tag run: | - git tag -a "${TAG_PREFIX}${NEW_VERSION}" -m "Release version ${NEW_VERSION}" + git tag -a "${TAG_PREFIX}${NEW_VERSION}" -m "bump version to ${TAG_PREFIX}${NEW_VERSION}" git push origin "${TAG_PREFIX}${NEW_VERSION}" - name: Create GitHub Release From cae957f9c1d919fccc27e85bc06eb13d3ce66115 Mon Sep 17 00:00:00 2001 From: umberto di fabrizio Date: Tue, 25 Feb 2025 17:45:12 +0100 Subject: [PATCH 3/4] remove notify slack action as redudant --- .github/workflows/version_bump.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 6b96d0f99..98f44d3bb 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -82,11 +82,3 @@ jobs: generate_release_notes: true draft: false prerelease: ${{ inputs.test_mode }} - - - name: Notify Slack - uses: ./.github/workflows/JOB_slack_message.yml - with: - icon: ":arrows_counterclockwise:" - message: | - ${{ inputs.test_mode && '[TEST] ' || '' }}Version ${{ env.TAG_PREFIX }}${{ env.NEW_VERSION }} has been bumped and tagged - Type: ${{ inputs.bump_type }} From 9b494474d7a59d46175b473e77cbbc9a99cf3669 Mon Sep 17 00:00:00 2001 From: umberto di fabrizio Date: Tue, 25 Feb 2025 17:52:43 +0100 Subject: [PATCH 4/4] avoiding recreating a relese since it's managed in EVENT_tag worfklow --- .github/workflows/version_bump.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 98f44d3bb..1a720002b 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -73,12 +73,3 @@ jobs: run: | git tag -a "${TAG_PREFIX}${NEW_VERSION}" -m "bump version to ${TAG_PREFIX}${NEW_VERSION}" git push origin "${TAG_PREFIX}${NEW_VERSION}" - - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ env.TAG_PREFIX }}${{ env.NEW_VERSION }} - name: ${{ env.TAG_PREFIX }}${{ env.NEW_VERSION }} - generate_release_notes: true - draft: false - prerelease: ${{ inputs.test_mode }}