@@ -130,31 +130,44 @@ jobs:
130130 publish_dir : ./public
131131
132132
133- release :
134- name : Releasing to PyPI
135- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && github.ref == 'refs/heads/main'
136- needs : [linters, pytest]
137- runs-on : ubuntu-latest
138- steps :
139- - uses : actions/checkout@v4
140- - name : Setup python
141- uses : actions/setup-python@v5
142- with :
143- python-version : " 3.10"
144-
145- - name : Install Poetry
146- uses : snok/install-poetry@v1
147-
148- - name : build release
149- run : poetry build
150-
151- - name : Publish package to PyPI
152- uses : pypa/gh-action-pypi-publish@release/v1
153- with :
154- user : __token__
155- password : ${{ secrets.PYPI_API_TOKEN }}
156-
157- - uses : actions/upload-artifact@v4
158- with :
159- name : build
160- path : dist/*
133+ release :
134+ name : Releasing to PyPI
135+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') # Trigger on tag push
136+ needs : [linters, pytest]
137+ runs-on : ubuntu-latest
138+ steps :
139+ - uses : actions/checkout@v4
140+
141+ - name : Setup python
142+ uses : actions/setup-python@v5
143+ with :
144+ python-version : " 3.10"
145+
146+ - name : Determine Source Branch
147+ id : get_branch
148+ run : echo "branch=$(git show -s --pretty=%D HEAD | grep -o 'origin/main')" >> $GITHUB_ENV
149+
150+ - name : Verify Source Branch is Main
151+ if : env.branch == 'origin/main'
152+ run : echo "Tag was created on main branch."
153+
154+ - name : Install Poetry
155+ if : env.branch == 'origin/main'
156+ uses : snok/install-poetry@v1
157+
158+ - name : Build release
159+ if : env.branch == 'origin/main'
160+ run : poetry build
161+
162+ - name : Publish package to PyPI
163+ if : env.branch == 'origin/main'
164+ uses : pypa/gh-action-pypi-publish@release/v1
165+ with :
166+ user : __token__
167+ password : ${{ secrets.PYPI_API_TOKEN }}
168+
169+ - uses : actions/upload-artifact@v4
170+ if : env.branch == 'origin/main'
171+ with :
172+ name : build
173+ path : dist/*
0 commit comments