-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add release PR workflow (#4849)
Co-authored-by: Trent Mick <trentm@gmail.com>
- Loading branch information
1 parent
30a46ae
commit b2778e1
Showing
3 changed files
with
127 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Create or Update Release PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
type: choice | ||
description: Release type | ||
options: | ||
- patch | ||
- minor | ||
release_scope: | ||
type: choice | ||
description: Release Scope | ||
options: | ||
- experimental | ||
- sdk | ||
- all | ||
|
||
jobs: | ||
create-or-update-release-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fork | ||
run: gh repo fork open-telemetry/opentelemetry-js | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: opentelemetrybot/opentelemetry-js | ||
ref: main | ||
token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
- name: Sync with upstream | ||
run: | | ||
git remote show origin | ||
git remote add upstream https://github.com/open-telemetry/opentelemetry-js.git | ||
git fetch upstream | ||
git reset --hard upstream/main | ||
git push origin main --force | ||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: 'npm' | ||
cache-dependency-path: package-lock.json | ||
node-version: 22 | ||
- run: npm install -g npm@latest | ||
|
||
- run: npm ci | ||
|
||
- name: Create/Update Release PR | ||
run: | | ||
git config user.name opentelemetrybot | ||
git config user.email 107717825+opentelemetrybot@users.noreply.github.com | ||
npm run github:create_or_update_release_pr | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,61 @@ | ||
# Releasing OpenTelemetry Packages | ||
|
||
This document explains how to publish all OT modules at version x.y.z. Ensure that you’re following semver when choosing a version number. | ||
|
||
Release Process: | ||
|
||
- [Release Process (Maintainers only)](#release-process) | ||
- [Update to latest locally](#update-to-latest-locally) | ||
- [Create a new branch](#create-a-new-branch) | ||
- [Prepare each package for release](#prepare-each-package-for-release) | ||
- [Use the Changelog to create a GitHub Release](#use-the-changelog-to-create-a-github-release) | ||
- [Generate the changelog with lerna](#generate-the-changelog-with-lerna) | ||
- [How to use](#how-to-use) | ||
- [Update Changelog file](#update-changelog-file) | ||
- [Create a new PR](#create-a-new-pr) | ||
- [Merge and pull](#merge-and-pull) | ||
- [Publish all packages](#publish-all-packages) | ||
- [Publish the GitHub Release](#publish-the-github-release) | ||
- [Update CHANGELOG](#update-changelog) | ||
- [Known Issues](#known-issues) | ||
|
||
## Release Process | ||
|
||
### Update to latest locally | ||
|
||
Use `git fetch` and `git checkout origin/main` to ensure you’re on the latest commit. Make sure you have no unstaged changes. Ideally, also use `git clean -dfx` to remove all ignored and untracked files. | ||
|
||
### Create a new branch | ||
|
||
Create a new branch called `x.y.z-proposal` from the current commit. | ||
|
||
### Prepare each package for release | ||
|
||
Decide on the next `major.minor.patch` release number based on [semver](http://semver.org/) guidelines. | ||
|
||
- Use `npm install` command to initialize all package directories | ||
- Use `lerna publish --skip-npm --no-git-tag-version --no-push` to bump the version in all `package.json` | ||
- Use `npm run bootstrap` to generate latest `version.ts` files | ||
|
||
### Use the Changelog to create a GitHub Release | ||
|
||
#### Generate the changelog with lerna | ||
|
||
Since we use `lerna`, we can use [lerna-changelog](https://github.com/lerna/lerna-changelog#lerna-changelog) | ||
|
||
##### How to use | ||
|
||
Pass your [github token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) to generate the changelog automatically. | ||
For security reasons, when you create a Github token, select the permissions: under **repo**, select **Access public repositories**, **Access commit status**. | ||
|
||
In your terminal, execute the following command: | ||
|
||
```bash | ||
GITHUB_AUTH=<your token> lerna-changelog | ||
``` | ||
|
||
It will print something like: | ||
|
||
```md | ||
### Unreleased (2018-05-24) | ||
|
||
##### :bug: Bug Fix | ||
* [#198](https://github.com/my-org/my-repo/pull/198) Avoid an infinite loop ([@helpful-hacker](https://github.com/helpful-hacker)) | ||
|
||
##### :house: Internal | ||
* [#183](https://github.com/my-org/my-repo/pull/183) Standardize error messages ([@careful-coder](https://github.com/careful-coder)) | ||
|
||
##### Commiters: 2 | ||
- Helpful Hacker ([@helpful-hacker](https://github.com/helpful-hacker)) | ||
- [@careful-coder](https://github.com/careful-coder) | ||
``` | ||
|
||
By default lerna-changelog will show all pull requests that have been merged since the latest tagged commit in the repository. That is however only true for pull requests **with certain labels applied** (see [lerna.json](lerna.json) for authorized labels). | ||
|
||
You can also use the `--from` and `--to` options to view a different range of pull requests: | ||
|
||
```sh | ||
GITHUB_AUTH=xxxxx lerna-changelog --from=v1.0.0 --to=v2.0.0 | ||
``` | ||
|
||
##### Update Changelog file | ||
|
||
From what `lerna-changelog` has generated, starts new Unreleased label. Follow the example set by recent Released label. | ||
|
||
On [GitHub Releases](https://github.com/open-telemetry/opentelemetry-js/releases), follow the example set by recent releases to populate a summary of changes, as well as a list of commits that were applied since the last release. Save it as a draft, don’t publish it. Don’t forget the tag -- call it `vx.y.z` and leave it pointing at `main` for now (this can be changed as long as the GitHub release isn’t published). | ||
|
||
### Create a new PR | ||
|
||
Create a pull request titled `chore: x.y.z release proposal`. The commit body should just be a link to the draft notes. Someone who can access draft notes should approve it, looking in particular for test passing, and whether the draft notes are satisfactory. | ||
|
||
### Merge and pull | ||
|
||
Merge the PR, and pull the changes locally (using the commands in the first step). Ensure that `chore: x.y.z release proposal` is the most recent commit. | ||
|
||
### Publish all packages | ||
|
||
Go into each directory and use `npm publish` (requires permissions) to publish the package. You can use the following script to automate this. | ||
|
||
```bash | ||
#!/bin/bash | ||
|
||
for dir in $(ls packages); do | ||
pushd packages/$dir | ||
npm publish | ||
popd | ||
done | ||
``` | ||
|
||
Check your e-mail and make sure the number of “you’ve published this module” emails matches the number you expect. | ||
|
||
### Publish the GitHub Release | ||
|
||
Publish the GitHub release, ensuring that the tag points to the newly landed commit corresponding to release proposal `x.y.z`. | ||
|
||
### Update CHANGELOG | ||
|
||
- After releasing is done, update the [CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-js/blob/main/CHANGELOG.md) and start new Unreleased label. | ||
- Create a new commit with the exact title: `Post Release: update CHANGELOG.md`. | ||
- Go through PR review and merge it to GitHub main branch. | ||
|
||
### Known Issues | ||
|
||
- The `examples/` and `getting-started/` folders are not part of lerna packages, we need to manually bump the version in `package.json`. | ||
# Releasing | ||
|
||
This document is aimed at Maintainers and describes how to release a new version of the packages contained in this repository. | ||
We aim to eventually automate this process as much as possible. | ||
|
||
## Create a release PR | ||
|
||
1. Go to the [Release PR Workflow](https://github.com/open-telemetry/opentelemetry-js/actions/workflows/create-or-update-release.yml) | ||
2. Click "Run workflow" | ||
3. For `Release Type`, select if you want to create a release PR for a new `minor` or `patch` version. | ||
4. For `Release Scope`, select if you want to release | ||
- `experimental` (all packages under `./experimental/packages`) | ||
- `sdk` (all packages under `./packages/` and `./experimental/packages`) | ||
- `all` (all packages under `./api/`, `./packages/` and `./experimental/packages`) | ||
|
||
> [!TIP] | ||
> If there was a commit to `main`, after PR creation simply run the workflow again before merging it. | ||
> Re-running it will update the PR with the contents from `main` and will update the PR body too. | ||
## Review and merge the release PR | ||
|
||
1. Review the PR generated via the workflow (it will be titled `chore: prepare next release` and opened by the @opentelemetrybot user) | ||
2. Once approved, merge the PR | ||
|
||
## Publish to NPM | ||
|
||
### Prerequisites | ||
|
||
1. Ensure you have access to the [`opentelemetry` npm organization](https://www.npmjs.com/org/opentelemetry) | ||
2. Go to your npm user's `Access Tokens` page | ||
3. Click `Generate New Token` -> `Granular Access Token` (2FA prompt will pop up) | ||
4. Input all required fields | ||
- recommended: set the expiry date on the token to 1 day | ||
- recommended: set a CIDR range to only allow your IP | ||
5. Under `Packages and Scopes` | ||
- set `Permissions` to `Read and Write` | ||
- Select `Only Select packages and scopes`, choose `@opentelemetry` | ||
|
||
### Publishing | ||
|
||
1. Check out the commit created by merging the release PR | ||
2. run `git clean -fdx --exclude <whatever you want to keep, e.g. .idea, .vscode>` | ||
3. run `npm ci` | ||
4. run `npm run compile` | ||
5. run `NODE_AUTH_TOKEN=<token generated earlier> npm run release:publish` | ||
|
||
> [!IMPORTANT] | ||
> Delete the token once you're done publishing | ||
## Create GitHub Releases | ||
|
||
1. Check out the commit created by merging the release PR | ||
2. Run | ||
- `npm run _github:draft_release:experimental`, if you published an `all`, `sdk` or `experimental` release | ||
- `npm run _github:draft_release:stable`, if you published an `all` or `sdk` release | ||
- `npm run _github:draft_release:api` if you published an `all` release | ||
3. Verify that the contents of the created draft releases (title, changelog, selected commit) | ||
4. Publish the releases | ||
- uncheck `Set as a pre-release` for all releases | ||
- uncheck `Set as the latest release` for all releases except for the `stable` SDK release. This will ensure that the | ||
`stable` SDK release consistently shows up as latest under `Releases` when navigating to the project page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters