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

Make manifest releases almost atomic using draft releases #19593

Merged
merged 3 commits into from Oct 9, 2019

Conversation

foolip
Copy link
Member

@foolip foolip commented Oct 9, 2019

No description provided.

Per https://developer.github.com/v3/repos/releases/#create-a-release,
`target_commitish` is used to create the tag, and ignored if the tag
already exists.
This makes tagging and releasing almost atomic, at most leaving behind
a draft release if something goes wrong. Because no tag or (non-draft)
release will be created in case of error, the script can just be run
again without first removing the bad release.
@foolip
Copy link
Member Author

foolip commented Oct 9, 2019

There are two commit on this branch where the first one would make sense in isolation and for review I recommend reading each commit message:

commit 01e7914f96131270c62da701fdf3ff29bd4a1af3
Author: Philip Jägenstedt <philip@foolip.org>
Date:   Wed Oct 9 11:37:37 2019 +0200

    Let `create_release` publish only after uploading assets
    
    This makes tagging and releasing almost atomic, at most leaving behind
    a draft release if something goes wrong. Because no tag or (non-draft)
    release will be created in case of error, the script can just be run
    again without first removing the bad release.

commit 41daef76e74df1728d226d271107ccbd7e173971
Author: Philip Jägenstedt <philip@foolip.org>
Date:   Wed Oct 9 10:16:10 2019 +0200

    Let `create_release` implicitly create the merge_pr_* tag
    
    Per https://developer.github.com/v3/repos/releases/#create-a-release,
    `target_commitish` is used to create the tag, and ignored if the tag
    already exists.

To gain some confidence that this works I make some local edits to the script to release to my fork, and emulated something going wrong when the .zst file was going to be uploaded. Here's the resulting draft release and the successful release once I removed the fake error:
https://github.com/foolip/wpt/releases/tag/untagged-72e17908aa7df0de1f69
https://github.com/foolip/wpt/releases/tag/merge_pr_19588

I've confirmed that no tag is created for drafts, even though you can't tell from the state of my repo right now.

release_id = create_resp["id"]
edit_url = "https://api.github.com/repos/%s/%s/releases/%s" % (owner, repo, release_id)
edit_data = {"draft": False}
edit_resp = request(edit_url, "Release publishing", json_data=edit_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this will do a POST request not PATCH?

Copy link
Member Author

@foolip foolip Oct 9, 2019

Choose a reason for hiding this comment

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

Yep, didn't spot the PATCH in https://developer.github.com/v3/repos/releases/#edit-a-release and it looks like GitHub accepts this.

The easy way to fix this is to add a method=None argument to request, but unless it's a string enum it would leak that fact that requests is being used within.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think adding a method argument that defaults to None is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've pushed a third commit to do just that, and verified that it could produce https://github.com/foolip/wpt/releases/tag/merge_pr_19493.

@foolip foolip merged commit f60b9f7 into master Oct 9, 2019
@foolip foolip deleted the foolip/manifest-draft branch October 9, 2019 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants