-
Notifications
You must be signed in to change notification settings - Fork 482
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
Automate cutting new releases #1141
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# This workflow is triggered three ways: | ||
# | ||
# 1. Manually triggering the workflow via the GitHub UI (Actions > Upload | ||
# package) will upload to test.pypi.org without the need to create a tag. | ||
# 2. When a tag is created, the workflow will upload the package to | ||
# test.pypi.org. | ||
# 3. When a GitHub Release is made, the workflow will upload the package to pypi.org. | ||
# | ||
# It is done this way until PyPI has draft reviews, to allow for a two-stage | ||
# upload with a chance for manual intervention before the final publication. | ||
name: Upload package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
push: | ||
tags: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -U tox | ||
- name: Create tox environments | ||
run: | | ||
tox -p -e py,build,release --notest | ||
- name: Run tests | ||
run: | | ||
tox -e py | ||
- name: Build package | ||
run: | | ||
tox -e build | ||
- name: Publish package | ||
env: | ||
TWINE_USERNAME: "__token__" | ||
run: | | ||
if [[ "$GITHUB_EVENT_NAME" == "push" || \ | ||
"$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then | ||
export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/" | ||
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}" | ||
elif [[ "$GITHUB_EVENT_NAME" == "release" ]]; then | ||
export TWINE_REPOSITORY="pypi" | ||
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}" | ||
else | ||
echo "Unknown event name: ${GITHUB_EVENT_NAME}" | ||
exit 1 | ||
fi | ||
tox -e release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should either trigger on "release" or on
workflow_dispatch
, but not on both.I'm inclined to say that we do it on
workflow_dispatch
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note triggering in workflow dispatch will allow us to test things. It will generate dev versions (as there won't be a tag) that will be uploaded to test.pypi.org.
Why do you think this is a bad idea? At the very least as a way to test changes in the publish logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and made this change myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have it backwards. For the other repos I have using this same workflow, the workflows were designed before "manually trigger an action" was a thing you could do, so I was using "made a GitHub release" as a way to get a manual step I could take in the UI to trigger the "final" release.
The way you've got it wired up, manual triggers and making a GitHub release both trigger the "do a final release" pipeline, which is unnecessary, and whichever one happens second will fail anyway, so I've just changed it so that the manual workflow triggering is the only way to finalize. We can still make GH releases, but we'll do it after everything is published to PyPI.