diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c0f6a9..dcf62e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Build and Release on: push: tags: - - 'v*.*.*' # Trigger on semantic versioning tags + - 'v*.*.*' # This triggers the workflow on tags following semantic versioning jobs: build: @@ -24,19 +24,6 @@ jobs: id: vars run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - name: Determine Branch - id: determine_branch - run: | - # Find the branch that contains the commit - if git branch -r --contains $GITHUB_SHA | grep "origin/master"; then - BRANCH_NAME="master" - elif git branch -r --contains $GITHUB_SHA | grep "origin/next"; then - BRANCH_NAME="next" - else - BRANCH_NAME="unknown" - fi - echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - - name: Install dependencies run: | python -m pip install --upgrade pip @@ -46,12 +33,25 @@ jobs: run: | python setup.py sdist bdist_wheel + - name: Create Release + id: create_release + run: | + if [[ "${GITHUB_REF}" == "refs/tags/v"* ]]; then + TAG_NAME=${GITHUB_REF#refs/tags/} + if [[ "${GITHUB_REF}" == "refs/tags/v"* ]]; then + echo "Creating release for tag $TAG_NAME" + echo "GITHUB_REF=$GITHUB_REF" >> $GITHUB_ENV + fi + else + echo "Not a valid tag, skipping release creation." + exit 0 + fi + - name: Upload Package to Release - if: startsWith(github.ref, 'refs/tags/v') # Run this step if the tag starts with 'v' + if: steps.create_release.outputs.tag_name != '' uses: softprops/action-gh-release@v1 with: - tag_name: ${{ env.VERSION }}-${{ env.BRANCH_NAME }} # Tag to create release - name: Release ${{ env.VERSION }} from branch ${{ env.BRANCH_NAME }} # Correct input 'name' for release title + tag_name: ${{ steps.create_release.outputs.tag_name }} files: | dist/* env: