Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't run publishing workflow on tags to avoid errors #45

Merged
merged 4 commits into from
Oct 15, 2020

Conversation

matthewfeickert
Copy link
Collaborator

@matthewfeickert matthewfeickert commented Oct 14, 2020

(This is a port of scikit-hep/pylhe#45)

With the old workflow if the publishing workflow was run after a new tag was created

$ bump2version <part>
$ git push origin master --tags

no release would get published to TestPyPI as the workflow that would get kicked off from the push event to master (and so NOT a tag event) would fail the "Verify untagged commits have dev versions" step

- name: Verify untagged commits have dev versions
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
latest_tag=$(git describe --tags)
latest_tag_revlist_SHA=$(git rev-list -n 1 ${latest_tag})
master_SHA="$(git rev-parse --verify origin/master)"
wheel_name=$(find dist/ -iname "*.whl" -printf "%f\n")
if [[ "${latest_tag_revlist_SHA}" != "${master_SHA}" ]]; then # don't check master push events coming from tags
if [[ "${wheel_name}" == *"pandamonium-0.1.dev"* || "${wheel_name}" != *"dev"* ]]; then
echo "python-build incorrectly named built distribution: ${wheel_name}"
echo "python-build is lacking the history and tags required to determine version number"
echo "intentionally erroring with 'return 1' now"
return 1
fi
else
echo "Push event to origin/master was triggered by push of tag ${latest_tag}"
fi
echo "python-build named built distribution: ${wheel_name}"

as it would

if: "!startsWith(github.ref, 'refs/tags/')"

but then also "${wheel_name}" != *"dev"* given that it comes from a tag. So nothing gets published.

Similarly, the workflow that would get kicked off from the tag event will just run though but will pass

- name: Publish distribution 📦 to Test PyPI
# every PR will trigger a push event on master, so check the push event is actually coming from master
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'dguest/pandamonium'
uses: pypa/[email protected]
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/

as it is has github.ref of 'refs/tags/' and so nothing happens at all.

This PR fixes that by just letting pushes to master publish to TestPyPI and then letting the releases publish to PyPI.

Suggested squash and merge commit message:

* Don't run publishing workflow on tag events
   - Avoid publishing errors due to 'push' or 'tag' events and checks for tags
* Update pypa/gh-action-pypi-publish action to v1.4.1

@matthewfeickert
Copy link
Collaborator Author

@dguest This is ready for review.

@matthewfeickert
Copy link
Collaborator Author

@dguest Done making small text changes now, so this is really ready for review.

@dguest dguest merged commit 271776e into dguest:master Oct 15, 2020
@dguest
Copy link
Owner

dguest commented Oct 15, 2020

I like this because it removes code and apparently also fixes bugs

@matthewfeickert matthewfeickert deleted the fix/correct-publishing-workflow branch October 15, 2020 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants