|
1 | 1 | # Publishing Guide for Maintainers |
2 | 2 |
|
3 | 3 | This document describes how to publish the `@hypercerts-org/lexicon` |
4 | | -package to npm using GitHub Actions workflows. All publishing |
5 | | -workflows are manually triggered to give you full control over when |
6 | | -releases are made. |
| 4 | +package to npm using GitHub Actions workflows with Changesets. All |
| 5 | +publishing workflows are manually triggered to give you full control |
| 6 | +over when releases are made. |
7 | 7 |
|
8 | 8 | ## Prerequisites |
9 | 9 |
|
10 | 10 | Before publishing, ensure you have: |
11 | 11 |
|
12 | 12 | 1. **GitHub Secrets configured:** |
13 | | - - `GH_PA_TOKEN`: GitHub Personal Access Token with permissions for |
14 | | - releases |
| 13 | + - `RELEASE_PAT`: GitHub Personal Access Token with permissions to bypass |
| 14 | + branch protection rules. Required for the beta release workflow that |
| 15 | + commits and pushes version changes to protected branches. |
| 16 | + - **Recommended:** Fine-grained Personal Access Token |
| 17 | + - Create at: <https://github.com/settings/tokens?type=beta> |
| 18 | + - Repository access: Select this repository |
| 19 | + - Repository permissions: `Contents` (read and write), `Metadata` |
| 20 | + (read-only) |
| 21 | + - **Alternative:** Classic Personal Access Token (if fine-grained |
| 22 | + doesn't work with your branch protection settings) |
| 23 | + - Create at: <https://github.com/settings/tokens> |
| 24 | + - Required scopes: `repo` (full control of private repositories) |
| 25 | + - This is needed because `GITHUB_TOKEN` cannot bypass branch protection |
| 26 | + - **Note:** Ensure branch protection rules allow the token to bypass |
| 27 | + protection (uncheck "Do not allow bypassing the above settings" or |
| 28 | + add the token as an allowed actor) |
15 | 29 | - `NPM_TOKEN`: npm access token with publish permissions for |
16 | 30 | `@hypercerts-org` scope |
17 | 31 |
|
18 | | -2. **GitHub Environments configured:** |
19 | | - - `test`: For the build-and-test job |
20 | | - - `staging`: For the semantic-release job |
| 32 | +## Adding Changesets |
21 | 33 |
|
22 | | -## Publishing a Release |
| 34 | +Before publishing, you need to create changesets for any user-facing |
| 35 | +changes: |
23 | 36 |
|
24 | | -To publish a new release to npm: |
| 37 | +```bash |
| 38 | +npm run changeset |
| 39 | +``` |
| 40 | + |
| 41 | +This will: |
| 42 | + |
| 43 | +1. Prompt you to select which packages changed |
| 44 | +2. Ask for the version bump type (major/minor/patch) |
| 45 | +3. Create a markdown file in `.changeset/` with your changes |
| 46 | + |
| 47 | +**Note:** Changesets generates files with random names (e.g., |
| 48 | +`beige-clowns-relax.md`). This is intentional to prevent filename |
| 49 | +collisions when multiple contributors create changesets simultaneously. |
| 50 | +The filename doesn't affect version ordering—Changesets uses git history |
| 51 | +to determine the order of changes. You can rename these files if desired, |
| 52 | +but it's not necessary and not recommended in collaborative environments. |
| 53 | + |
| 54 | +## Publishing a Stable Release |
| 55 | + |
| 56 | +To publish a stable release to npm: |
25 | 57 |
|
26 | 58 | 1. **Navigate to GitHub Actions:** |
27 | 59 | - Go to the repository on GitHub |
28 | 60 | - Click on the "Actions" tab |
29 | 61 |
|
30 | 62 | 2. **Select the workflow:** |
31 | | - - Choose "Build and release" from the workflow list |
| 63 | + - Choose "Release" from the workflow list |
32 | 64 |
|
33 | 65 | 3. **Run the workflow:** |
34 | 66 | - Click "Run workflow" |
35 | 67 | - Select the branch (typically `main`) |
36 | 68 | - Click "Run workflow" to start |
37 | 69 |
|
38 | 70 | 4. **What happens:** |
39 | | - - The workflow runs linting and regenerates TypeScript types |
40 | | - - If successful, semantic-release analyzes your commits |
41 | | - - If there are version-worthy changes, it: |
42 | | - - Determines the new version based on |
43 | | - [Conventional Commits](https://www.conventionalcommits.org/) |
44 | | - - Updates `CHANGELOG.md` |
45 | | - - Creates a GitHub release |
46 | | - - Publishes to npm with the new version |
| 71 | + - The workflow validates the code and regenerates TypeScript types |
| 72 | + - If there are pending changesets, it creates a "Release Pull Request" |
| 73 | + - Merge the Release PR to publish to npm with the `latest` tag |
| 74 | + - If no changesets exist, nothing is published |
47 | 75 |
|
48 | | -## Publishing a Prerelease |
| 76 | +## Publishing a Beta Release |
49 | 77 |
|
50 | 78 | To publish a beta/prerelease version: |
51 | 79 |
|
52 | 80 | 1. **Navigate to GitHub Actions:** |
53 | 81 | - Go to the "Actions" tab |
54 | 82 |
|
55 | | -2. **Select the prerelease workflow:** |
56 | | - - Choose "Build and release - staging" |
| 83 | +2. **Select the workflow:** |
| 84 | + - Choose "Release Beta" |
57 | 85 |
|
58 | 86 | 3. **Run the workflow:** |
59 | 87 | - Click "Run workflow" |
60 | | - - Select the branch (typically `develop` or a feature branch) |
| 88 | + - Select the branch (must be `main`) |
61 | 89 | - Click "Run workflow" |
62 | 90 |
|
63 | 91 | 4. **What happens:** |
64 | | - - Same process as above, but publishes with a `beta` tag |
65 | | - - Version format: `1.2.3-beta.1`, `1.2.3-beta.2`, etc. |
| 92 | + - The workflow enters beta prerelease mode (if not already) |
| 93 | + - Versions packages based on pending changesets |
| 94 | + - Publishes to npm with the `beta` tag |
| 95 | + - Version format: `0.9.0-beta.1`, `0.9.0-beta.2`, etc. |
| 96 | + - Commits and pushes version changes back to the repository |
| 97 | + |
| 98 | +**Note:** This workflow requires the `RELEASE_PAT` secret to bypass |
| 99 | +branch protection rules when pushing version changes. |
66 | 100 |
|
67 | 101 | ## Validating Releases (PRs) |
68 | 102 |
|
69 | | -When you open a pull request, the "Build and release - staging" |
70 | | -workflow automatically runs in dry-run mode to: |
| 103 | +When you open a pull request, the "PR Check" workflow automatically |
| 104 | +runs to: |
71 | 105 |
|
72 | | -- Validate that the code builds successfully |
73 | | -- Check that types regenerate correctly |
74 | | -- Show what version would be released (without actually publishing) |
| 106 | +- Check if package changes (lexicons, types, package.json) have |
| 107 | + corresponding changesets |
| 108 | +- Warn if changesets are missing |
75 | 109 |
|
76 | | -This helps catch issues before merging. |
| 110 | +This helps ensure all user-facing changes are properly documented |
| 111 | +before merging. |
77 | 112 |
|
78 | 113 | ## Version Management |
79 | 114 |
|
80 | | -Versions are automatically determined by semantic-release based on |
81 | | -commit messages: |
| 115 | +Versions are determined by Changesets: |
| 116 | + |
| 117 | +- **Patch**: Bug fixes and minor updates (0.9.0 → 0.9.1) |
| 118 | +- **Minor**: New features (0.9.0 → 0.10.0) |
| 119 | +- **Major**: Breaking changes (0.9.0 → 1.0.0) |
82 | 120 |
|
83 | | -- `feat:` → minor version bump (1.0.0 → 1.1.0) |
84 | | -- `fix:` → patch version bump (1.0.0 → 1.0.1) |
85 | | -- `BREAKING CHANGE:` or `!` → major version bump (1.0.0 → 2.0.0) |
| 121 | +You specify the version bump type when creating a changeset with |
| 122 | +`npm run changeset`. |
86 | 123 |
|
87 | 124 | The `prepublishOnly` script ensures types are regenerated before |
88 | 125 | publishing, so the published package always includes the latest |
|
0 commit comments