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

feat: add release PR workflow #4849

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Jul 5, 2024

Part of the series of PRs to automate the release process.

This PR:

  • adds a workflow to create release PRs using the @opentelemetrybot user
  • the workflow will also update an existing PR if run so no need to check if a PR is open before running it
  • the user has to choose a scope (sdk = all SDK packages, experimental and stable, experimental = all packages in experimental, all = all release packages, including API) and type (patch = bump patch version for the selected scope, minor = bump minor version for the selected scope). major is not included right now as it's not a regular enough occurrence to spend time on it.

Still missing:

@pichlermarc pichlermarc marked this pull request as ready for review July 5, 2024 14:59
@pichlermarc pichlermarc requested a review from a team July 5, 2024 14:59
@@ -43,7 +43,7 @@
"prepare_release:sdk:patch": "npm run _check:no_changes && npm run _backup:package-json && npm run _lerna:remove_api && npm run _lerna:version_patch && npm run _restore:package-json && npm run _changelog:prepare_experimental && npm run _changelog:prepare_stable",
"prepare_release:sdk:minor": "npm run _check:no_changes && npm run _backup:package-json && npm run _lerna:remove_api && npm run _lerna:version_minor && npm run _restore:package-json && npm run _changelog:prepare_experimental && npm run _changelog:prepare_stable",
"prepare_release:all:minor": "npm run _check:no_changes && npm run _backup:package-json && npm run _lerna:remove_api && npm run _lerna:version_minor && cd api/ && npm version minor && cd .. && lerna run align-api-deps && npm run _restore:package-json && npm run _changelog:prepare_all",
"release:publish": "lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access",
"release:publish": "lerna publish --concurrency 1 from-package --no-push --no-private --no-git-tag-version --no-verify-access",
Copy link
Member Author

Choose a reason for hiding this comment

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

Reviewer note: I've had trouble publishing without limiting concurrency in the past. Sometimes, it tries to publish a package while a dependency is not available yet and exits with an error. Having --concurrency 1 will take slightly longer but will avoid running into a state where only a portion of the packages are published.

Comment on lines +56 to +59
RELEASE_SCOPE: ${{ github.event.inputs.release_scope }}
RELEASE_KIND: ${{ github.event.inputs.release_scope }}:${{ github.event.inputs.release_type }}
RELEASE_PR_REMOTE: origin
RELEASE_PR_OWNER: opentelemetrybot
Copy link
Member Author

@pichlermarc pichlermarc Jul 5, 2024

Choose a reason for hiding this comment

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

Reviewer note: If we don't have a fork on @opentelemetrybot yet and we need to release, the way to create a PR would be to set all these env vars and locally and running the npm run github:create_or_update_release_pr script above (gh CLI needs to be logged in).

For me this would be:

RELEASE_SCOPE: [any one of these values]
RELEASE_KIND: $RELEASE_SCOPE: [any one of these values]
RELEASE_PR_REMOTE: origin (the name of the remote that I usually push to)
RELEASE_PR_OWNER: dynatrace-oss-contrib (the organization that owns my fork of the repo)

You can adjust these values and run the script locally to get the same result as you'd get from running the workflow. The only dfference: instead of @opentelemetrybot it will then be your user that's opening the PR (but that still beats doing everything manually). 🙂

Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

Thanks for working on automatic and documenting this!

doc/releasing.md Outdated Show resolved Hide resolved
doc/releasing.md Outdated Show resolved Hide resolved
.github/workflows/create-or-update-release-pr.yml Outdated Show resolved Hide resolved
.github/workflows/create-or-update-release-pr.yml Outdated Show resolved Hide resolved
doc/releasing.md Outdated Show resolved Hide resolved
doc/releasing.md Outdated Show resolved Hide resolved
@pichlermarc
Copy link
Member Author

pichlermarc commented Jul 29, 2024

I just figured out we can actually use gh repo fork open-telemetry/opentelemetry-js to fork the repo to the @opentelemetrybot user, so no manual intervention by the TC is necessary for this to work. 🙂 Didn't occur to me to try for some reason when I was working on this a few weeks back.

Edit: see afb0d23, fea0e64

runs-on: ubuntu-latest
steps:
- name: Fork
run: gh repo fork open-telemetry/opentelemetry-js
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we only need to do this fork once, and then change this workflow? I would have thought the forking would be a one-time thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can just run the forking step every time we run the workflow, as it's just a single API call. Since the gh binary is already available, it does only add about a second to the workflow run. If the fork already exists, then this command will exit with a success code, logging that the fork already exists, effectively becoming a no-op. 🙂

Here's an example where I tested that: https://github.com/pichlermarc-sample-organization/test-release-pr/actions/runs/10147085271/job/28056647373 🙂

@pichlermarc pichlermarc added this pull request to the merge queue Aug 1, 2024
Merged via the queue into open-telemetry:main with commit b2778e1 Aug 1, 2024
19 checks passed
@pichlermarc pichlermarc deleted the feat/add-release-pr-workflow branch August 1, 2024 09:15
Zirak pushed a commit to Zirak/opentelemetry-js that referenced this pull request Sep 14, 2024
Co-authored-by: Trent Mick <trentm@gmail.com>
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.

3 participants