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

Add a release workflow to GitHub Actions #257

Merged
merged 1 commit into from
Jul 13, 2024
Merged

Conversation

charliermarsh
Copy link
Collaborator

Summary

This PR moves the release workflow to GitHub Actions, which removes the need for wrangling PATs and other access controls locally.

Specifically, we now have a "Release" workflow that runs via workflow_dispatch, and accepts the commit SHA and the tag as arguments. You can run the workflow on a specific branch, which defaults to main, so the commit on which the release workflow runs does not need to match the commit being released, which IMO is a nice property.

The workflow is idempotent, such that it's safe to re-run with the same commit and tag if the release has already started, or completed, or failed partway through.

There's also a "dry-run" mode that avoids creating the release or uploading any artifacts. (If the release does exist, it will go a bit "further" in the process.)

Closes #253.
Closes #256.

Test Plan

This took an embarrassing amount of trial and error, but feels pretty good now.

prerelease: true
body: TBD
allowUpdates: true
updateOnlyUnreleased: true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this with gh, but the action is helpful because of these allowUpdates and updateOnlyUnreleased properties.

This action is also used in cargo-dist (and therefore we use it in ruff and uv), so feels well-trodden.

# Push the tag to GitHub.
- name: Push tag
if: ${{ github.event.inputs.dry-run == 'false' }}
run: git push origin ${{ github.event.inputs.tag }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a long time to figure this out, but it seems that you cannot create a GitHub Release from an action by specifying a commit and tag. I fought 403 errors endlessly (omitting the commit worked without error), regardless of whether I used the gh CLI or the action below. So, ultimately, I now have to create and push the tag, then create a release by specifying just the tag.

@charliermarsh charliermarsh added the release Related to the release process label Apr 21, 2024
@@ -48,7 +48,7 @@ async fn upload_release_artifact(
dry_run: bool,
) -> Result<()> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes in this file are just making upload_release_artifact more robust in dry-run, such that if the release itself doesn't exist, it can still do some validation.

@charliermarsh charliermarsh merged commit 7dcdddd into main Jul 13, 2024
476 checks passed
@charliermarsh
Copy link
Collaborator Author

I'm going to bias towards merging this so that I can use it for an upcoming release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Related to the release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move release process to GitHub Actions just release should be idempotent
1 participant