|
| 1 | +# Releasing |
| 2 | + |
| 3 | +Kirby has two kinds of publish. Both run on CI and authenticate to npm with |
| 4 | +[trusted publishing][trusted-publishing] over OIDC — there are no npm tokens anywhere in |
| 5 | +this repository. |
| 6 | + |
| 7 | +| | Release publish | Dev publish | |
| 8 | +| --------- | ---------------------------------------- | ---------------------------------------- | |
| 9 | +| Trigger | Pushing a protected tag | Manual dispatch of `publish-dev.yml` | |
| 10 | +| Who | Repository admins | Repository admins | |
| 11 | +| Version | Exactly what is in `libs/*/package.json` | `<version>-dev-<short SHA>` | |
| 12 | +| dist-tag | `latest` | `dev` | |
| 13 | +| Supported | Yes | No — see [Dev publishes](#dev-publishes) | |
| 14 | + |
| 15 | +## Publishable packages |
| 16 | + |
| 17 | +| Package | Source | Depends on | |
| 18 | +| --------------------------------- | ------------------------- | -------------- | |
| 19 | +| `@kirbydesign/core` | `libs/core` | — | |
| 20 | +| `@kirbydesign/designsystem` | `libs/designsystem` | `core` | |
| 21 | +| `@kirbydesign/extensions-angular` | `libs/extensions/angular` | `designsystem` | |
| 22 | +| `@kirbydesign/stylelint-plugin` | `libs/stylelint-plugin` | — | |
| 23 | + |
| 24 | +## Release publishes |
| 25 | + |
| 26 | +1. Open a release PR bumping the version in the relevant `libs/*/package.json`. |
| 27 | +2. Once merged, an admin pushes the matching tag. Tag creation is restricted by a |
| 28 | + repository ruleset, which is what makes releasing admin-only. |
| 29 | + |
| 30 | +| Tag | Workflow | Publishes | |
| 31 | +| --------------------------- | -------------------------------- | ---------------------- | |
| 32 | +| `vX.Y.Z` | `publish.yml` | `core`, `designsystem` | |
| 33 | +| `vX.Y.Z-extensions-angular` | `publish-extensions-angular.yml` | `extensions-angular` | |
| 34 | +| `vX.Y.Z-stylelint-plugin` | `publish-stylelint-plugin.yml` | `stylelint-plugin` | |
| 35 | + |
| 36 | +## Dev publishes |
| 37 | + |
| 38 | +A dev publish lets a consumer install an unreleased change into a real application before |
| 39 | +it is released. |
| 40 | + |
| 41 | +> [!WARNING] |
| 42 | +> Dev versions are **permanent, unsupported, and never removed**. npm's OIDC tokens |
| 43 | +> authenticate `npm publish` only — `npm unpublish`, `npm deprecate` and `npm dist-tag rm` |
| 44 | +> all require a long-lived token, which this repository deliberately does not have. Never |
| 45 | +> reference a dev version from a production dependency. |
| 46 | +
|
| 47 | +### Producing one |
| 48 | + |
| 49 | +Actions → **Publish dev version to npm** → **Run workflow** → pick the branch and the |
| 50 | +package → **Run workflow**. The run then waits on the `npm-dev-publish` environment; an |
| 51 | +admin clicks **Review deployments** → **Approve and deploy** on the run page. Admins can |
| 52 | +approve their own dispatch. |
| 53 | + |
| 54 | +When it finishes, the run summary lists every published version and the exact |
| 55 | +`npm install` command to hand to the consumer. |
| 56 | + |
| 57 | +### What gets published |
| 58 | + |
| 59 | +A dev publish publishes the chosen package **and everything it depends on**, because these |
| 60 | +are peer dependencies and npm enforces them: |
| 61 | + |
| 62 | +| Chosen | Published | |
| 63 | +| -------------------- | -------------------------------------------- | |
| 64 | +| `core` | `core` | |
| 65 | +| `designsystem` | `core`, `designsystem` | |
| 66 | +| `extensions-angular` | `core`, `designsystem`, `extensions-angular` | |
| 67 | +| `stylelint-plugin` | `stylelint-plugin` | |
| 68 | + |
| 69 | +Inter-package peer dependency ranges are rewritten to the exact dev versions. This is not |
| 70 | +cosmetic: a prerelease never satisfies a caret range, so a dev `designsystem` still asking |
| 71 | +for `"@kirbydesign/core": "^0.0.92"` would make the consumer's `npm install` fail with |
| 72 | +`ERESOLVE`. Install the whole set the run summary lists, not just one package. |
| 73 | + |
| 74 | +### Versions and tags |
| 75 | + |
| 76 | +A dev version looks like `11.11.0-dev-abc1234` — the package's current version with the |
| 77 | +commit appended as a prerelease identifier. Two consequences worth knowing: |
| 78 | + |
| 79 | +- **Nothing resolves to it by accident.** npm excludes prereleases from ranges, so |
| 80 | + `11.11.0-dev-abc1234` satisfies neither `^11.11.0` nor `>=11.0.0`. A consumer only ever |
| 81 | + gets a dev build by asking for that exact version. |
| 82 | +- **The `dev-` infix is required.** A bare SHA such as `0123456` is a leading-zero numeric |
| 83 | + identifier and not valid SemVer, which would break roughly one publish in 270. |
| 84 | + |
| 85 | +Every dev publish uses the single dist-tag `dev`, which points at whichever dev publish ran |
| 86 | +most recently. It carries no meaning — always pin the exact version. |
| 87 | + |
| 88 | +Re-running a dispatch for the same commit is safe: any package whose dev version already |
| 89 | +exists is skipped, so a run that failed part way through can simply be re-run. |
| 90 | + |
| 91 | +## Running the publish script locally |
| 92 | + |
| 93 | +`npm run publish -- <package>` off CI does **not** publish. It builds and writes a tarball |
| 94 | +to `dist/`, which you can install with `npm install <path to tarball>`. Dev publishes are |
| 95 | +refused entirely outside CI, because they rewrite `libs/*/package.json` in place. |
| 96 | + |
| 97 | +## Adding a new publishable package |
| 98 | + |
| 99 | +1. Publish the first version manually — a trusted publisher cannot be registered for a |
| 100 | + package that does not yet exist on the registry. |
| 101 | +2. Register a trusted publisher for its release workflow. |
| 102 | +3. Register a second trusted publisher for `publish-dev.yml`, with environment |
| 103 | + `npm-dev-publish`. |
| 104 | +4. Add it to `sourcePackageJsonPaths` and `publishChains` in `scripts/publish.js`, and to |
| 105 | + the `package` input of `.github/workflows/publish-dev.yml`. |
| 106 | + |
| 107 | +Each package may have up to 10 trusted publishers, but an existing one cannot be edited — |
| 108 | +only deleted and recreated. |
| 109 | + |
| 110 | +[trusted-publishing]: https://docs.npmjs.com/trusted-publishers |
0 commit comments