Publish to PyPI from release instead of master.

Still require commits to be tagged.
This commit is contained in:
Dominik Moritz Roth 2024-01-18 11:00:10 +01:00
parent aa652e3610
commit b05dcb84c4

View File

@ -2,29 +2,27 @@ name: Publish Python package to PyPI
on: on:
push: push:
tags: branches:
- '*' - release
jobs: jobs:
publish: publish:
name: Publish to PyPI name: Publish to PyPI
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: false && startsWith(github.ref, 'refs/tags/') # Only run on tagged commits
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # This fetches all history for all branches and tags fetch-depth: 0 # This fetches all history for all branches and tags
- name: Verify tag is on master branch - name: Check if commit is tagged
run: | run: |
TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master') TAG=$(git tag --contains HEAD)
if [ -z "$TAG_IS_ON_MASTER" ]; then if [ -z "$TAG" ]; then
echo "Tag is not on the master branch. Cancelling the workflow." echo "Commit is not tagged. Failing the workflow."
exit 1 exit 1
fi fi
echo "Tag is on the master branch. Proceeding with the workflow." echo "Commit is tagged. Proceeding with the workflow."
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4