@@ -3,7 +3,7 @@ name: Build and Release
33on :
44 push :
55 tags :
6- - ' v*.*.*' # Trigger on semantic versioning tags
6+ - ' v*.*.*' # This triggers the workflow on tags following semantic versioning
77
88jobs :
99 build :
2424 id : vars
2525 run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
2626
27- - name : Determine Branch
28- id : determine_branch
29- run : |
30- # Find the branch that contains the commit
31- if git branch -r --contains $GITHUB_SHA | grep "origin/master"; then
32- BRANCH_NAME="master"
33- elif git branch -r --contains $GITHUB_SHA | grep "origin/next"; then
34- BRANCH_NAME="next"
35- else
36- BRANCH_NAME="unknown"
37- fi
38- echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
39-
4027 - name : Install dependencies
4128 run : |
4229 python -m pip install --upgrade pip
@@ -46,12 +33,25 @@ jobs:
4633 run : |
4734 python setup.py sdist bdist_wheel
4835
36+ - name : Create Release
37+ id : create_release
38+ run : |
39+ if [[ "${GITHUB_REF}" == "refs/tags/v"* ]]; then
40+ TAG_NAME=${GITHUB_REF#refs/tags/}
41+ if [[ "${GITHUB_REF}" == "refs/tags/v"* ]]; then
42+ echo "Creating release for tag $TAG_NAME"
43+ echo "GITHUB_REF=$GITHUB_REF" >> $GITHUB_ENV
44+ fi
45+ else
46+ echo "Not a valid tag, skipping release creation."
47+ exit 0
48+ fi
49+
4950 - name : Upload Package to Release
50- if : startsWith(github.ref, 'refs/tags/v') # Run this step if the tag starts with 'v '
51+ if : steps.create_release.outputs.tag_name != ' '
5152 uses : softprops/action-gh-release@v1
5253 with :
53- tag_name : ${{ env.VERSION }}-${{ env.BRANCH_NAME }} # Tag to create release
54- name : Release ${{ env.VERSION }} from branch ${{ env.BRANCH_NAME }} # Correct input 'name' for release title
54+ tag_name : ${{ steps.create_release.outputs.tag_name }}
5555 files : |
5656 dist/*
5757 env :
0 commit comments