-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make the release workflow more resilient #4728
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 |
---|---|---|
|
@@ -2,8 +2,17 @@ name: "[ruff] Release" | |
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [ published ] | ||
inputs: | ||
tag: | ||
description: "The version to tag, without the leading 'v'. If omitted, will initiate a dry run skipping uploading artifact." | ||
type: string | ||
sha: | ||
description: "Optionally, the full sha of the commit to be released" | ||
type: string | ||
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 don't think this is used (at least, as far as I can tell). 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. Aren't we able to select a branch anyway in the UI? 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 can be useful in cases where you want to re-run the release workflow on a specific commit. But you're right. We could create a branch pointing to that specific commit instead. 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've changed this to be an additional check you can opt in or ignore |
||
push: | ||
paths: | ||
# When we change pyproject.toml, we want to ensure that the maturin builds still work | ||
- pyproject.toml | ||
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'd be fine to omit this and just do it manually, personally. 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. yes but i want tests for maturin updates :D |
||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
@@ -394,7 +403,8 @@ jobs: | |
- linux-cross | ||
- musllinux | ||
- musllinux-cross | ||
if: "startsWith(github.ref, 'refs/tags/')" | ||
# If you don't set an input it's a dry run skipping uploading artifact | ||
if: ${{ inputs.tag }} | ||
environment: | ||
name: release | ||
permissions: | ||
|
@@ -403,11 +413,34 @@ jobs: | |
# For GitHub release publishing | ||
contents: write | ||
steps: | ||
- name: Consistency check tag | ||
run: | | ||
version=$(grep "version = " pyproject.toml | sed -e 's/version = "\(.*\)"/\1/g') | ||
if [ "${{ inputs.tag }}" != "${version}" ]; then | ||
echo "The input tag does not match the version from pyproject.toml:" >&2 | ||
echo "${{ inputs.tag }}" >&2 | ||
echo "${version}" >&2 | ||
exit 1 | ||
MichaReiser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
echo "Releasing ${version}" | ||
fi | ||
- name: Consistency check sha | ||
if: ${{ inputs.sha }} | ||
run: | | ||
git_sha=$(git rev-parse HEAD) | ||
if [ "${{ inputs.sha }}" != "${git_sha}" ]; then | ||
echo "The specified sha does not match the git checkout" >&2 | ||
echo "${{ inputs.sha }}" >&2 | ||
echo "${git_sha}" >&2 | ||
exit 1 | ||
else | ||
echo "Releasing ${git_sha}" | ||
fi | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: wheels | ||
path: wheels | ||
- name: "Publish to PyPi" | ||
- name: Publish to PyPi | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
skip-existing: true | ||
|
@@ -417,10 +450,20 @@ jobs: | |
with: | ||
name: binaries | ||
path: binaries | ||
- name: git tag | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Ruff Release CI" | ||
git tag -m "v${{ inputs.tag }}" "v${{ inputs.tag }}" | ||
# If there is duplicate tag, this will fail. The publish to pypi action will have been a noop (due to skip | ||
# existing), so we make a non-destructive exit here | ||
git push --tags | ||
- name: "Publish to GitHub" | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
files: binaries/* | ||
tag_name: v${{ inputs.tag }} | ||
|
||
# After the release has been published, we update downstream repositories | ||
# This is separate because if this fails the release is still fine, we just need to do some manual workflow triggers | ||
|
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.
What's the difference here?
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.
one works by bash globbing, the other is the pip-provided way if installing from a directory which abstract wheel naming and such away and also works if there are multiple wheels (pip selects the right one)