diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 299da91..c79b2e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,6 +59,8 @@ jobs: release-on-push: if: github.event.pull_request.merged || inputs.version_bump != '' runs-on: 'ubuntu-latest' + env: + TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} steps: - name: Checkout Code uses: actions/checkout@v6 @@ -67,7 +69,7 @@ jobs: - name: Retrieve last tag on branch run: | - git checkout ${{ github.base_ref }} + git checkout "$TARGET_BRANCH" echo "TAG_NAME=$(git describe --tags --match "v*.*.*" --abbrev=0 | cut -c 2-)" >> $GITHUB_OUTPUT id: last_tag @@ -101,16 +103,16 @@ jobs: - name: Debug branch name run: | - echo current branch ${{ github.base_ref }} + echo current branch $TARGET_BRANCH - name: Exit on bad tag - if: ${{ (inputs.version_bump == 'major' || (inputs.version_bump == '' && contains(github.event.pull_request.labels.*.name, 'release:major'))) && !contains(github.base_ref, inputs.main_branch) }} + if: ${{ (inputs.version_bump == 'major' || (inputs.version_bump == '' && contains(github.event.pull_request.labels.*.name, 'release:major'))) && !contains(env.TARGET_BRANCH, inputs.main_branch) }} run: | - echo Can't create a major release on branch ${{ github.base_ref }} + echo Can't create a major release on branch $TARGET_BRANCH exit 1 - name: Exit on bad branch - if: ${{ !contains(fromJson(inputs.dist_branches), github.base_ref) }} + if: ${{ !contains(fromJson(inputs.dist_branches), env.TARGET_BRANCH) }} run: | - echo Can't create a release on branch ${{ github.base_ref }} + echo Can't create a release on branch $TARGET_BRANCH exit 1 - name: Prepare release tag env var @@ -189,7 +191,7 @@ jobs: if: ${{ !contains(env.RELEASE_VERSION, 'undefined') && (inputs.version_ini_path != '' || inputs.toml_conf_path != '' || inputs.package_json_version == 'true') }} with: commit_message: "chore: update version" - branch: ${{ github.base_ref }} + branch: ${{ env.TARGET_BRANCH }} - name: Create release and tag if: ${{ !contains(env.RELEASE_VERSION, 'undefined') }} @@ -197,7 +199,7 @@ jobs: with: name: 'Release ${{ env.RELEASE_VERSION }}' tag: 'v${{ env.RELEASE_VERSION }}' - commit: ${{ github.base_ref }} + commit: ${{ env.TARGET_BRANCH }} generateReleaseNotes: true outputs: