|
| 1 | +# Release Process |
| 2 | + |
| 3 | +This repository uses **semantic-release** to fully automate versioning and publishing of the GitHub Action. |
| 4 | + |
| 5 | +For details on securely signing release commits and using a GitHub App token, see the companion guide: [Release Signing & GitHub App](./Release_Signing_and_GitHub_App.md). |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +1. Developers raise pull requests with source changes only (no `dist/` directory committed). |
| 10 | +2. The pull request workflow performs a semantic-release dry run to preview the next version. |
| 11 | +3. Once changes are merged to `main`, the publish workflow: |
| 12 | + |
| 13 | + - Checks out the code. |
| 14 | + - Installs dependencies and builds the production bundle with `npm run package` (emits `dist/index.js` + `licenses.txt`). |
| 15 | + - Runs `semantic-release` which: |
| 16 | + - Calculates the next version from Conventional Commits. |
| 17 | + - Updates release notes and creates a Git tag `vX.Y.Z`. |
| 18 | + - Commits the generated `dist/` assets, updated `package.json` / `package-lock.json` version metadata, and the `VERSION` file via the `@semantic-release/git` plugin. |
| 19 | + - Creates a GitHub Release. |
| 20 | + - Updates the moving major tag (e.g. `v1`) to the new version tag. |
| 21 | + - (If repository secrets `GITHUB_APP_SIGNING_KEY`, `GITHUB_APP_SIGNING_KEY_ID`, and `GITHUB_APP_SIGNING_KEY_PASSPHRASE` are configured) imports the GPG key and signs the release commit and tag using a GitHub App. |
| 22 | + |
| 23 | +## Rationale |
| 24 | + |
| 25 | +Bundling only at release time avoids large, noisy diffs in pull requests and guarantees that the published artefact matches the exact commit that semantic-release tags. |
| 26 | + |
| 27 | +## Usage for Consumers |
| 28 | + |
| 29 | +Reference the Action via a tag, ideally the major tag: |
| 30 | + |
| 31 | +```yaml |
| 32 | +uses: nhs-england-tools/notify-msteams-action@v1 |
| 33 | +``` |
| 34 | +
|
| 35 | +Pin to a specific minor/patch if you require full immutability: |
| 36 | +
|
| 37 | +```yaml |
| 38 | +uses: nhs-england-tools/notify-msteams-action@v1.2.3 |
| 39 | +``` |
| 40 | +
|
| 41 | +Avoid using `@main` externally, because the branch does not contain a guaranteed built `dist/` bundle. |
| 42 | + |
| 43 | +## Developer Workflow |
| 44 | + |
| 45 | +```bash |
| 46 | +# Install dependencies |
| 47 | +npm ci |
| 48 | +# Run tests & quality gates |
| 49 | +npm test |
| 50 | +npm run lint |
| 51 | +# Build bundle for local testing (not committed) |
| 52 | +npm run package |
| 53 | +``` |
| 54 | + |
| 55 | +You can validate the action locally by creating a temporary workflow that uses `uses: ./`. |
| 56 | + |
| 57 | +## Conventional Commit Examples |
| 58 | + |
| 59 | +| Type | Purpose | Example | |
| 60 | +|-------|-----------------------------------------|------------------------------------------------| |
| 61 | +| `feat` | New feature (minor bump) | `feat: support custom message colour` | |
| 62 | +| `fix` | Bug fix (patch bump) | `fix: correct adaptive card JSON schema` | |
| 63 | +| `chore` | Build/tooling changes | `chore: update eslint config` | |
| 64 | +| `docs` | Documentation updates | `docs: add release process guide` | |
| 65 | +| `perf` | Performance improvement | `perf: reduce bundle size` | |
| 66 | +| `refactor` | Non-functional code change | `refactor: simplify card builder` | |
| 67 | + |
| 68 | +Breaking changes: add `!` (`feat!:`) or a `BREAKING CHANGE:` footer. |
| 69 | + |
| 70 | +## Failing Conditions |
| 71 | + |
| 72 | +The guard job fails a pull request if `dist/` is present. Remove it before requesting review. |
| 73 | + |
| 74 | +## Manual Intervention |
| 75 | + |
| 76 | +If a release must be re-run (rare): |
| 77 | + |
| 78 | +1. Revert the release commit if necessary. |
| 79 | +2. Amend commit messages to adjust semantic meaning. |
| 80 | +3. Push to `main` again and allow the publish workflow to execute. |
| 81 | + |
| 82 | +Avoid editing tags directly; let semantic-release manage them. |
| 83 | + |
| 84 | +## Future Improvements |
| 85 | + |
| 86 | +- Add changelog generation (`@semantic-release/changelog`) if a persistent `CHANGELOG.md` is desired. |
| 87 | +- Add an integration test workflow that consumes the just-published tag. |
| 88 | + |
| 89 | +--- |
| 90 | +Maintainers: ensure `permissions: contents: write` is preserved in the publish workflow for tag/commit operations. |
| 91 | + |
| 92 | +### Commit Signing with GitHub App |
| 93 | + |
| 94 | +If branch protection requires signed commits, this repository uses GitHub App native commit signing: |
| 95 | + |
| 96 | +1. Create a GitHub App with commit signing enabled and generate both authentication and signing keys. |
| 97 | +2. Configure the following repository secrets: |
| 98 | + - `GITHUB_APP_ID`: GitHub App ID for authentication |
| 99 | + - `GITHUB_APP_PRIVATE_KEY`: App private key (PEM format) for token generation |
| 100 | + - `GITHUB_APP_SIGNING_KEY_ID`: GPG key ID for commit signing |
| 101 | + - `GITHUB_APP_SIGNING_KEY`: ASCII-armoured GPG private key content |
| 102 | + - `GITHUB_APP_SIGNING_KEY_PASSPHRASE`: Passphrase for the GPG signing key |
| 103 | + |
| 104 | +On publish, the workflow: |
| 105 | + |
| 106 | +1. Generates a GitHub App installation token for authentication. |
| 107 | +2. Creates a GPG wrapper script that handles passphrase injection automatically. |
| 108 | +3. Imports the GPG signing key and configures git to use the wrapper script. |
| 109 | +4. Runs semantic-release which creates signed commits and tags attributed to the GitHub App. |
| 110 | + |
| 111 | +If the signing secrets are absent, semantic-release proceeds with unsigned commits (which will fail if branch protection mandates signatures—therefore the secrets must be present in that case). |
| 112 | + |
| 113 | +Complete setup procedures (key generation, GitHub App configuration, rotation, revocation) are documented in [Release Signing & GitHub App](./Release_Signing_and_GitHub_App.md). |
0 commit comments