Skip to content

Latest commit

 

History

History
245 lines (184 loc) · 12.5 KB

RELEASING.md

File metadata and controls

245 lines (184 loc) · 12.5 KB

Releasing

Packages are released by tagging their read-only split repositories in the opentelemetry-php organization. This repository's workflows prepare releases of both monorepos, this one (core) and contrib. Contrib has issues turned off, and only this repository can use the bot's key, so contrib's release starts here too.

The workflows run dev-tools. Its README covers each command in detail.

Contents

See what is ready to release

Each monorepo has a release dashboard issue in this repository:

It shows what a release from main would hold now:

  • the packages with unreleased changes, the version each would get, and a count of entries per section
  • the order to tag them in
  • under Check before releasing, each breaking entry, cut to its first sentence
  • under Check the constraints between packages, each package whose composer.json or #[PackageDependency] excludes another package's new version
  • under No version suggested, each package with changes whose latest tag is a pre-release or can't be parsed
  • each package's entries, collapsed

The version comes from the sections under Unreleased in each package's CHANGELOG.md, as described in Write changelog entries.

The dashboard is rewritten on each push to core's main and once a day. Contrib merges and new releases don't trigger it, so after one the issue is behind until the next rewrite. Edits to the issue are lost at the next rewrite. Only the boxes at its foot do anything.

Fix what the dashboard shows

When a version is wrong because of the changelog, such as an entry under the wrong section or a missing entry, fix the changelog in a pull request to main. The dashboard then shows the fix, and so does every later release pull request.

Use an override in the release pull request for a version the changelog can't give, such as a major with no breaking entries, or to hold a package back. See Change a version or skip a package. An override lasts only as long as that pull request.

A package under No version suggested is not released until an override gives it a version. The dashboard's --set hint is the command-line form of the same thing.

Read each warning before opening the release pull request:

  • A constraint warning usually means a dependent's constraint must be widened on main first.
  • Any warning puts a box in the release pull request. In core, the Release approval check fails until it is ticked. See Approve breaking changes.

Use the dashboard boxes

The foot of each dashboard issue has two boxes. Ticking one starts a workflow, which unticks it.

Box What it does When to tick it
Refresh now Rewrites the issue After a contrib merge or a release, to see the result before the daily rewrite
Open a release PR Opens the release pull request, or rebuilds the open one from the tip of main To start a release, and to rebuild one after main moves

If a box is still ticked a few minutes later, its run failed, or gave way to another queued run. Check the latest run of Release dashboard or Release PR, then untick it and tick it again. A tick that has nothing to do changes nothing. The next rewrite unticks every box, so after that only the run shows the failure.

Open a release pull request

Tick Open a release PR at the foot of the dashboard issue. Or run the Release PR workflow and choose the monorepo. A tick needs write access to that monorepo, and running the workflow needs write access to core.

The workflow runs release:prep on main, which dates each changelog section and moves the branch aliases. It commits the result as otelbot-php[bot] to the branch otelbot/release, and opens a pull request in the monorepo. Contrib's pull request is in contrib. If one is already open, it is rebuilt instead. When there is nothing left to release, the open pull request is closed.

The description shows the versions, the tag order and the warnings. Review it, and the changelogs in the diff, as you would any release.

To fix a changelog entry, change it in a pull request to main, then rebuild. A commit pushed to otelbot/release is lost at the next rebuild.

Change a version or skip a package

The description ends with an overrides block. Add one line per package, as <package>=<version|skip>. The package is the composer name or the split repository name:

```overrides
sdk=1.16.0
open-telemetry/exporter-zipkin=skip
```

In core, saving the description rebuilds the pull request with the overrides. Edits to contrib's pull request start no workflow, so save, then rebuild. A rebuild keeps the overrides.

An invalid line fails the rebuild, and the run names it. In core, the Release approval check fails while the overrides in the description are not the ones the pull request was built with, so it stays failed until a rebuild succeeds.

If the pull request has conflicts, saving the description doesn't rebuild it, as GitHub starts no pull request workflow then. Tick Open a release PR on the dashboard issue, or run the Release PR workflow.

Approve breaking changes

When a package records breaking changes, gets a new major version, or breaks a constraint between packages, the description has a Breaking changes section with a box:

- [ ] I have read the breaking changes

Read the warnings, then tick it. In core, the Release approval check fails until you do. Deleting the box or the comment under it doesn't pass the check, as the release commit records that the warnings need a tick. A rebuild keeps the tick while the warnings are the same, and clears it when they change.

Rebuild after main moves

Nothing rebuilds the pull request when main moves. Merged as it is, the release would ship the changes merged since, with their changelog entries still under Unreleased. So the workflow adds a note to the top of the description instead, on each push to core's main and daily for contrib. In core, the Release approval check then fails.

To rebuild, tick Open a release PR on the dashboard issue again, or run the Release PR workflow. Don't use Update branch or rebase the branch. Either brings in main without dating the new entries, and the Release approval check fails on it.

Merge and tag

Merge the release pull request once it is approved and its checks pass. gitsplit then pushes each package to its split repository.

Two more jobs in the same gitsplit run then tag the release. The run is in the monorepo the release is for: core or contrib.

  1. Plan the release runs release:run --dry-run on the merge commit, and comments on the pull request with the versions it would tag.
  2. Tag the release waits for approval. Check the comment, open the run from its link, and approve the job under Review deployments. It runs release:run and comments with a link to each release. In core it also refreshes the dashboard. Contrib's job can't reach this repository, so tick Refresh now on contrib's dashboard, or wait for the daily rewrite.

If the dry run finds a problem, such as a split that gitsplit hasn't pushed, the comment lists it and nothing is tagged. Fix it, then tag by hand.

Rejecting the job tags nothing. If it fails partway, rerun it. Packages already tagged are skipped, including any tagged by hand since the comment.

Tag by hand

If the tag job can't run, tag by hand. Run release:run from a full checkout of the monorepo at the release's merge commit. It needs a token that can create releases in the opentelemetry-php organization, which only its administrators have. See Create a GitHub token.

git fetch origin
git checkout <merge commit>
composer install
export GITHUB_TOKEN=<fine-grained-token>
vendor/bin/otel release:run --path=. --sha=<merge commit> --dry-run
vendor/bin/otel release:run --path=. --sha=<merge commit>

--sha tags the merge commit, not the tip of main, so a later merge is not released by mistake. Packages are tagged in the order the description shows. If the run stops because gitsplit hasn't pushed yet, wait and run it again. Packages already tagged are skipped.

Release without the workflows

The workflows run the same commands a maintainer can run from a checkout. If they are unavailable, follow Release a monorepo, step by step.

What the workflows need

Workflow What it does
release-dashboard.yml Rewrites the dashboard issues
release-pr.yml Opens and rebuilds the release pull requests, and adds the note when main moves
release-approval.yml The Release approval check on core's release pull request
split-monorepo.yaml, and split_monorepo.yaml in contrib Pushes each package to its split repository, and tags the monorepo's releases

The dashboard workflow fails unless exactly one open issue has the dashboard's label. To replace one that was closed or deleted, open an issue titled Release dashboard: core or Release dashboard: contrib, label it release-dashboard:core or release-dashboard:contrib, then run the Release dashboard workflow to write it.

The release pull requests are opened by the otelbot-php GitHub App, so their checks run like any other pull request's. This repository needs the OTELBOT_PHP_CLIENT_ID variable and the OTELBOT_PHP_PRIVATE_KEY secret. The app needs contents and pull requests write on core and contrib.

The Release approval check blocks a merge only once it is a required status check on main, which a repository administrator sets. It is skipped on other pull requests, which counts as passing. Contrib has no copy of the check yet, as a workflow here can't see contrib's pull requests.

The tag job runs in the monorepo's release environment. Core and contrib each have one, which a repository administrator set up under Settings, Environments, with:

  • Required reviewers: the maintainers who may approve a tag. Leave Prevent self-review off, so the maintainer who merged can approve.
  • Deployment branches and tags: main only.
  • In core, the OPENTELEMETRY_PHP_CLIENT_ID variable and OPENTELEMETRY_PHP_PRIVATE_KEY secret of the opentelemetry-php GitHub App, which an administrator of the opentelemetry-php organization can create a key for. Contrib has them as repository settings already, for gitsplit, and the tag job reads those.

The tag job waits for approval only while the environment has required reviewers. So the plan job checks for them first, and without them it fails and tags nothing.

The tag job uses the app to make a token that expires in an hour and can only create releases on the split repositories, which it reads from .gitsplit.yml. The app is installed on every repository in the organization, so a new split needs nothing more.

The key itself can do more than the token, and the runner holds it for the rest of the job. The job installs dev-tools from dev-main and the monorepo's dependencies without a lock file, so a compromised package could read the key.