-
Notifications
You must be signed in to change notification settings - Fork 310
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
Add GitHub workflow for making releases #945
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,67 @@ | ||||||||||||
name: Release | ||||||||||||
|
||||||||||||
on: | ||||||||||||
release: | ||||||||||||
types: | ||||||||||||
- published | ||||||||||||
|
||||||||||||
jobs: | ||||||||||||
build: | ||||||||||||
name: Build artifacts | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
permissions: | ||||||||||||
id-token: write | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure nothing uses this. Did you mean to set |
||||||||||||
outputs: | ||||||||||||
hashes: ${{ steps.hash.outputs.hashes }} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see no such step. |
||||||||||||
steps: | ||||||||||||
- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf | ||||||||||||
|
||||||||||||
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 | ||||||||||||
with: | ||||||||||||
python-version: "3.x" | ||||||||||||
|
||||||||||||
- name: deps | ||||||||||||
run: python -m pip install -U build | ||||||||||||
|
||||||||||||
- name: build | ||||||||||||
run: python -m build | ||||||||||||
|
||||||||||||
- name: Upload built packages | ||||||||||||
uses: actions/upload-artifact@v3 | ||||||||||||
with: | ||||||||||||
name: built-packages | ||||||||||||
path: ./dist/ | ||||||||||||
if-no-files-found: warn | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not error out? |
||||||||||||
|
||||||||||||
release-pypi: | ||||||||||||
needs: [build] | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strongly recommend putting that token in an environment:
Suggested change
The environment with the name |
||||||||||||
runs-on: ubuntu-latest | ||||||||||||
permissions: {} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, you could drop all the privileges on the workflow level additionally. |
||||||||||||
steps: | ||||||||||||
- name: Download artifacts diretories # goes to current working directory | ||||||||||||
uses: actions/download-artifact@v3 | ||||||||||||
|
||||||||||||
- name: publish | ||||||||||||
uses: pypa/gh-action-pypi-publish@d7edd4c95736a5bc1260d38b5523f5d24338bc25 | ||||||||||||
with: | ||||||||||||
user: __token__ | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not necessary, it's already the default
Suggested change
|
||||||||||||
password: ${{ secrets.PYPI_TOKEN }} | ||||||||||||
packages_dir: built-packages/ | ||||||||||||
|
||||||||||||
release-github: | ||||||||||||
needs: [build] | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
permissions: | ||||||||||||
# Needed to upload release assets. | ||||||||||||
contents: write | ||||||||||||
steps: | ||||||||||||
- name: Download artifacts diretories # goes to current working directory | ||||||||||||
uses: actions/download-artifact@v3 | ||||||||||||
|
||||||||||||
- name: Upload artifacts to github | ||||||||||||
# Confusingly, this action also supports updating releases, not | ||||||||||||
# just creating them. This is what we want here, since we've manually | ||||||||||||
# created the release that triggered the action. | ||||||||||||
uses: softprops/action-gh-release@v1 | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is also possible to create discussions attached to the releases. Example: https://github.com/cherrypy/cheroot/releases/tag/v9.0.0 (there's a button at the bottom). I started doing this in my automations. |
||||||||||||
with: | ||||||||||||
files: built-packages/* |
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.
Lately I've been preferring the workflow_dispatch event — it allows me to type in the version number I want and both PyPI and GH releases get created with that.
I can also make Git updates like generating the changelog, bumping the version, making a tag, and pushing that as a part of the workflow, making sure all the steps are automated, lowering the possibility of human errors as much as possible.