-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
unified release process #4986
unified release process #4986
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4986-all-demos You can install the changes in this PR by running: pip install https://gradio-builds.s3.amazonaws.com/d51f61692b0bdb001bf902bbc02a24ed6fc1109d/gradio-3.38.0-py3-none-any.whl |
…vascript packages.
Very cool @pngwn! Thanks for putting this together. I looked through the changes, I couldn't follow everything, but changes look good at a high level. Down to test it out with the next release |
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
- name: generate changeset | ||
uses: "gradio-app/github/actions/generate-changeset@main" | ||
with: | ||
github_token: ${{ secrets.PAT }} |
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 just checked and @gradio-pr-bot is in the org so I think we can use secrets.COMMENT_TOKEN
here.
user: __token__ | ||
passwords: | | ||
gradio-test-pypi:${{ secrets.PYPI_API_TOKEN }} |
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.
These tokens look good to me.
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.
@pngwn the CI master !!! Excited to test this out!!
Thanks so much for taking the time to explain the changes here so elaborately! It'd be great to keep this documentation somewhere as an easily accessible reference for contributors instead of digging up this PR. |
js/button/README.md
Outdated
@@ -1,4 +1,4 @@ | |||
# `@gradio/button` | |||
# `@gradio/boop` |
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 need to remove my boop 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.
ah, yes.
if: (github.event.workflow_run.head_repository.full_name == 'gradio-app/gradio' && github.event.workflow_run.head_branch != 'main') || github.event.workflow_run.head_repository.full_name != 'gradio-app/gradio' | ||
steps: | ||
- id: 'get-pr' | ||
uses: "gradio-app/github/actions/get-pr-branch@main" |
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.
is this doing the same as the 8BitJonny/gh-get-current-pr@2.2.0
action in deploy-chromatic.yml?
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.
It's similar but not quite the same. I'm not 100% certain if that action would work for us as ours is tailored for workflow runs (and doesn't require any input), we use the branch name + repo owner to check the PR rather than a commit sha which is what i think that action is doing. It could work tho, not certain.
🎉 Chromatic build completed! There are 0 visual changes to review. |
closes #4851.
This PR overhauls our versioning and release process, and unifies it across the JS and Python files/libraries.
Before I explain this PR I just want to point out that change will increase the frequency with which you have to pull changes from a PR branch because the bot will be pushing to the PR. There should never be conflicts because it will only create
changeset
files (so.changeset/something.md
) but you may get errors if you try to push and you have pulled when the bot has added a commit.In order to work around this, I recommend setting up some global git config to make pulling easier:
These settings will automatically setup up the tracking branch for you (as long as you are working off this repo). If you need to pull you'll just be able to
git pull
without tracking remote explicitly and you'll also be able to justgit push
instead ofgit push origin whatever
. You don't have to do this but it'll make life way easier. Being able to justpush
/pull
is super nice.There are quite a few moving parts in this PR (honestly it was a much more enormous amount of work than i expected), so I'll will explain what happens and then i will explain how.
What does it do
This PR introduces two distinct things: automatic versioning/ changelog generation/ release and automatic changeset generation. This will make sense in a sec.
Whenever we make a PR that requires a release (so any code change) instead of updating the changelog manually, we just add a
changeset
file that describe the change. The only information needed is:patch
,minor
ormajor
)fix
,feat
,highlight
). This is to allow us to format our changelogs nicely for each releases. We can add moretypes
if we thing they are necessary.A changeset file looks like this:
A changeset with a
highlight
type ha slightly different requirements:highlight
types must have a level 4 markdown heading on a separate line from thehighlight:
text. This looks nicer and is validated in CI.When this file is added to a PR and that PR is merged, a robot will create a new 'release' PR this PR takes care of figuring our the correct version bump for each package based on the combined changesets file, it also generates a changelog from those changesets. It link the PR, the merge commit and thanks the user (with a link) in the change logs. Normal entries look like this:
Rendered:
highlight entries look like this:
Rendered:
This generated PR also bumps all of the version files (package.json + version.txt) and bumps the version of any local dependencies (so when
gradio_client
gets bumped, therequirements.txt
ofgradio
gets bumped to match this version).When we merged this PR, the second part of teh same CI workflow will see that the changesets have been removed + the version updated. It will then check that version does not exist, run any build scripts and release the package. Python packages are expected to have a
build_pypi.sh
script in their directory (we can move this toscripts/
if needed).changesets
will also generate tags + github releases but I need to double check that is enabled.The second part os the automatic changeset generation. Generating the changesets can be a bit tedious so we have a bot that does it for you. The bot does this:
minor
and the type asfeat
.v: (patch|major|minor)
for the bump type andt: (fix|feat|highlight)
for the 'type'.How does it work
Changeset generation
pull_request
event orissues_edited
is the event used here).workflow_run
event). This is for security reasons. We need access to secrets to do anything but we don't want PRs from forks to have access to those secrets.pull_request
evens do not expose secrets. This 'other' action runs in the context of main, so a PR would need to be merged any code within it could have any impact.gradio
changelog in order to be useful to users. This isn't typically how it works in JS. The default behaviour is for individual packages to contain their changelog (which is good) but for packages that depend on those packages to simple contain an 'dependencies updated' changelog entry (which is not very useful). So I have introduced amain_changeset
field to the package.json of any package whose changelog should be added to the 'main' package, in this casegradio
. What this mean is that if you change thePlot
component's JS/Svelte code with a title of "ensure the plot uses the correct styling in dark mode" that description will be added to the@gradio/plot
package (which is nice for us to keep track) but it will also be added to thegradio
package (which is nice for our users).Versioning
package.json
files to the gradio libs, to kind of treat them as 'packages' (changesets only really works with npm packages).type
(fix
,feat
,highlight
). So when making PRs and merging them intomain
the flow is pretty consistent with the changesets documentation../changeset/changeset.cjs
and./changeset/fix_changelogs.cjs
../changeset/changeset.cjs
has a function or two that run for every 'release line', i.e. every changelog entry for each package. We do some github api lookups to get some details about a PR, parse the changeset file to see if it is afix
,feat
, orhighlight
and then write those details to a JSON file. These function also return a string that becomes the new changelog for each package but we don't care about that because we overwrite them in the next step.changeset version
command, which also bumps the JS packages. As we are storing the version for python packages inpackage.json
files they get bumped correctly, however they are not in the correct place (version.txt
), so we need to copy those new version into a few places to play nice with the python conventions. This is also when see if any python packages depend on another python package locally. In this casegradio
depends ongradio_client
. Ifgradio_client
has been bumped, then we will update therequirements.txt
ofgradio
to match this new version. This is because that is how we tests in CI, latest with latest, so that is what we pin to.Highlights
, "Features", and "Fixes" sections). We use the JSON file we saved earlier to know what has changed for each package.changesets
action creates a descriptive PR message from the changelogs themselves, so this pretty much works without any intervention.Publishing
This is also part of the 'changesets' CI job.
build_pypi.sh
script that ever package is expected to havetwine
checklist for me as i go through.
pngwn/gradio
reference to ``gradio-app/gradio`