diff --git a/.github/workflows/EVENT_tag.yml b/.github/workflows/EVENT_tag.yml deleted file mode 100644 index 897b8ed24..000000000 --- a/.github/workflows/EVENT_tag.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: created_tag -run-name: Created Tag - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - 'test-*' - -concurrency: - group: created_tag - cancel-in-progress: true - -env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -permissions: - contents: read - -jobs: - create_release: - name: Create Release - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Harden Runner - uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Checkout - with: - ref: ${{ github.head_ref || github.ref }} - - - name: Create release - uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 - env: - GITHUB_TOKEN: ${{ env.GH_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: true - prerelease: false diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index b4ae2d28e..de43da623 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -1,5 +1,5 @@ -name: Version Bump -run-name: Version bump ${{ github.event_name == 'workflow_dispatch' && inputs.bump_type || 'patch' }}${{ github.event_name == 'workflow_dispatch' && inputs.test_mode && ' (TEST)' || '' }} +name: Version Bump and Release +run-name: Version bump and release ${{ github.event_name == 'workflow_dispatch' && inputs.bump_type || 'patch' }}${{ github.event_name == 'workflow_dispatch' && inputs.test_mode && ' (TEST)' || '' }} on: workflow_dispatch: @@ -18,6 +18,10 @@ on: required: true default: false type: boolean + commit_sha: + description: "Specific commit SHA to start from (optional)" + required: false + type: string pull_request: types: [opened, synchronize, reopened] @@ -60,30 +64,36 @@ jobs: if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then BUMP_TYPE="${{ inputs.bump_type }}" TEST_MODE="${{ inputs.test_mode }}" + COMMIT_SHA="${{ inputs.commit_sha }}" else BUMP_TYPE="patch" # Default to "patch" for pull requests TEST_MODE="true" # Always run in test mode for pull requests + COMMIT_SHA="" fi echo "BUMP_TYPE=${BUMP_TYPE}" >> $GITHUB_ENV echo "TEST_MODE=${TEST_MODE}" >> $GITHUB_ENV + echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV - name: Bump version run: | + if [ -n "${{ env.COMMIT_SHA }}" ]; then + git checkout ${{ env.COMMIT_SHA }} + fi python deploy/increase_version.py --${{ env.BUMP_TYPE }} --auto-confirm y BASE_VERSION=$(grep '__version__' darwin/version/__init__.py | cut -d '"' -f 2) if [[ "${{ env.TEST_MODE }}" == "true" ]]; then TIMESTAMP=$(date +%Y%m%d%H%M%S) - TEST_VERSION="${BASE_VERSION}-test.${TIMESTAMP}" + + TAG_PREFIX="test-" + NEW_VERSION="${BASE_VERSION}.${TIMESTAMP}" + TEST_VERSION="${TAG_PREFIX}${NEW_VERSION}" echo "Adding test suffix" # Update version in pyproject.toml and in __init__.py awk -v new_version="$TEST_VERSION" '/^version = / {$0 = "version = \"" new_version "\""} 1' pyproject.toml > pyproject.tmp && mv pyproject.tmp pyproject.toml awk -v new_version="$TEST_VERSION" '/^__version__ = / {$0 = "__version__ = \"" new_version "\""} 1' darwin/__init__.py > darwin/__init__.tmp && mv darwin/__init__.tmp darwin/__init__.py - NEW_VERSION="${BASE_VERSION}-test.${TIMESTAMP}" - echo $NEW_VERSION - TAG_PREFIX="test-" - BRANCH_NAME="test/version-bump-${NEW_VERSION}" + BRANCH_NAME="${TAG_PREFIX}branch-${NEW_VERSION}" else NEW_VERSION="${BASE_VERSION}" TAG_PREFIX="v" @@ -105,7 +115,7 @@ jobs: run: | echo "Commit and push version changes" git add pyproject.toml darwin/__init__.py - git commit -m "Version bump to ${{ env.NEW_VERSION }}" + git commit -m "Version bump to ${{ env.TAG_PREFIX}}${{ env.NEW_VERSION }}" git push origin HEAD:${BRANCH_NAME} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -125,3 +135,13 @@ jobs: git push origin "${TAG_PREFIX}${NEW_VERSION}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.TAG_PREFIX}}${{ env.NEW_VERSION }} + release_name: ${{ env.TAG_PREFIX}}${{ env.NEW_VERSION }} + draft: true + prerelease: false