You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/src/publishing.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,4 +102,14 @@ It's common to create a release on GitHub when publishing a package. This includ
102
102
103
103
## Automating the process
104
104
105
-
This scaffolding tool doesn't currently have any support for automating this process, but you can find various examples of automation scripts if you look through the GitHub repos for large projects.
105
+
Several parts of the publishing process can be automated. You can find various examples of automation scripts if you look through the GitHub repos for large projects.
106
+
107
+
This scaffolding tool provides configuration for using *trusted publishing* via a GitHub Action. It will be included if you answered `Yes` to the question *[Include GitHub configuration for publishing to npm?](questions#include-npm-publish)*.
108
+
109
+
The workflow configuration is in `.github/workflows/publish.yml`. You'll also need to enable trusted publishing in the settings for your package on the npm registry:
110
+
111
+
-https://docs.npmjs.com/trusted-publishers
112
+
113
+
The first time you publish your package you'll need to do it manually, then you can enable trusted publishing for subsequent releases.
114
+
115
+
You should check the contents of `publish.yml` to ensure you understand what it's doing. It will build and publish the package, but it won't handle any other part of the release process. The other steps, such as updating the version number in `package.json`, are still down to you.
Copy file name to clipboardExpand all lines: packages/docs/src/questions.md
+19-6Lines changed: 19 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,7 @@
54
54
<spanclass="check">✔</span> <ahref="#include-playground">Include playground application for development? … No / Yes</a>
55
55
<spanclass="check">✔</span> <ahref="#include-github-ci">Include GitHub CI configuration? … No / Yes</a>
56
56
<spanclass="check">✔</span> <ahref="#include-pkg-pr-new">Include pkg.pr.new in CI configuration? … No / Yes</a>
57
+
<spanclass="check">✔</span> <ahref="#include-npm-publish">Include GitHub configuration for publishing to npm? … No / Yes</a>
57
58
<spanclass="check">✔</span> <ahref="#include-examples">Include example code? … No, just configs / Yes</a>
58
59
<spanclass="check">✔</span> <ahref="#configure-src-alias">Configure @ as an alias for src? … No / Yes</a>
59
60
<spanclass="check">✔</span> <ahref="#configure-test-variable">Configure global __TEST__ variable? … No / Yes</a></pre>
@@ -141,7 +142,7 @@ The GitHub path should be in the form `username/repo-name`.
141
142
142
143
For example, this project has its repository at `https://github.com/skirtles-code/create-vue-lib`, so the GitHub path is `skirtles-code/create-vue-lib`.
143
144
144
-
While answering this question is optional, it can be especially useful if you intend to use GitHub Pages to host your documentation, as the generated configuration files will be much closer to their final form.
145
+
While answering this question is optional, it can be especially useful if you intend to use GitHub Pages to host your documentation, as the generated configuration files will be much closer to their final form. It is also used in some of the workflow configurations for GitHub Actions to help ensure they don't run on forks.
145
146
146
147
## Include Tailwind CSS?{#include-tailwind-css}
147
148
@@ -221,22 +222,34 @@ The playground application will use your library direct from the source code, wi
221
222
222
223
## Include GitHub CI configuration?{#include-github-ci}
223
224
224
-
Continuous Integration (CI) is used to help catch problems as soon as they occur.
225
+
*Continuous integration* (CI) is used to help catch problems as soon as they occur.
225
226
226
-
This option will include a GitHub Actions configuration for a CI workflow. It will run the `lint`, `type-check`, `build` and `test:unit` targets from the `scripts` section of the root `package.json`. The workflow is triggered by any PRs opened against the `main` branch, as well as when changes are pushed to `main`.
227
-
228
-
If a [GitHub path](#github-path) has been provided, the job will be configured so that it only runs for that specific fork.
227
+
This option will include a GitHub Actions configuration for a CI workflow. It will run the `lint`, `type-check`, `build` and `test:unit` targets from the `scripts` section of the root `package.json`. The workflow is triggered when a PR is opened or when new commits are pushed to a branch.
229
228
230
229
## Include pkg.pr.new in CI configuration?{#include-pkg-pr-new}
231
230
232
231
:::info NOTE
233
232
You'll only see this question if you chose to include GitHub CI configuration.
234
233
:::
235
234
236
-
[pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) allows for continuous releases. Every PR and every commit to `main` will be published as a package on pkg.pr.new, which is similar to the npm registry but with each 'release' tied to a specific commit rather than a version number. This allows changes to be installed and tested before they're merged or released to npm.
235
+
[pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) allows for *continuous releases*. Every PR and every commit to a branch will be published as a package on pkg.pr.new, which is similar to the npm registry but with each 'release' tied to a specific commit rather than a version number. This allows changes to be installed and tested before they're merged or released to npm.
237
236
238
237
You'll also need to install the [pkg.pr.new GitHub App](https://github.com/apps/pkg-pr-new) and enable it on your GitHub repository.
239
238
239
+
## Include GitHub configuration for publishing to npm?{#include-npm-publish}
240
+
241
+
The recommended way to publish a package to the npm registry is via *trusted publishing*:
242
+
243
+
-https://docs.npmjs.com/trusted-publishers
244
+
245
+
If you'd like to publish your package using a GitHub Action then select this option. It will include a suitable workflow in `.github/workflow/publish.yml` with trusted publishing enabled.
246
+
247
+
By default, this workflow will only run when it is triggered manually, via the **Actions** tab of your GitHub repository.
248
+
249
+
You will also need to configure trusted publishing for your package on the npm registry. This can only be done for packages that already exist, so the first release of your package won't be able to use the automated workflow.
Copy file name to clipboardExpand all lines: packages/docs/src/why.md
+38-6Lines changed: 38 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ The project's root `package.json` uses `preinstall` and `postinstall` hooks. It'
32
32
33
33
## TypeScript configuration
34
34
35
-
The TypeScript configuration is mostly done of a per-package basis. The configuration files are closely based on the files created by `create-vue`.
35
+
The TypeScript configuration is mostly done on a per-package basis. The configuration files are closely based on the files created by `create-vue`.
36
36
37
37
A root-level `tsconfig.json` is only created if ESLint is included. That is just used to check `eslint.config.ts`, which is at the root of the project. There currently aren't any other TS files that live outside the sub-packages.
38
38
@@ -112,9 +112,27 @@ For `__TEST__` we replace the value with a simple `true` or `false`, which can b
112
112
113
113
For `__DEV__` it's a little more complicated, because in some builds we replace it with `!(process.env.NODE_ENV === "production")`. This allows the downstream bundler to make the decision about what mode we're in. We can't use `define` for a complex value like this, so `@rollup/plugin-replace` is used instead.
114
114
115
-
## `pages.yml`
115
+
## GitHub Action workflows
116
116
117
-
The file `.github/worksflows/pages.yml` configures the GitHub Pages workflow for the documentation. The exact name of the file is not important, GitHub will run all workflows configured in `.github/workflows`.
117
+
The files in `.github/workflows` are workflow configurations for GitHub Actions. The exact names of these files aren't important, GitHub will load all workflows in that directory and run them as needed.
118
+
119
+
Different workflows need to run at different times. This is controlled via the `on` setting, which specifies exactly which events should trigger the workflow. Some events can also be filtered further to target specific branches, tags or file paths within the repo.
120
+
121
+
It's also necessary to consider how workflows should behave on forks. If other contributors fork your repo on GitHub then they'll also copy the workflow configurations. For a CI workflow, building and testing changes on the fork is probably what you'd want. But a workflow for deploying the documentation probably shouldn't be enabled on a fork.
122
+
123
+
Where relevant, the workflows will try to use an `if` check on `github.repository` to ensure that they only run on the original repo. This can only be configured correctly if you provided a [GitHub path](questions#github-path) when running the scaffolding tool.
124
+
125
+
### `ci.yml`
126
+
127
+
Depending on exactly which options you picked, the CI workflow will build the project (including the docs and playground), run the tests, linting and type checking. It's also responsible for [deploying to pkg.pr.new](questions#include-pkg-pr-new).
128
+
129
+
### `pages.yml`
130
+
131
+
:::info NOTE
132
+
You'll also need to enable GitHub Pages in the settings for your repo.
133
+
:::
134
+
135
+
The file `.github/worksflows/pages.yml` configures the GitHub Pages workflow for the documentation.
118
136
119
137
The configuration is similar to those found at:
120
138
@@ -123,11 +141,25 @@ The configuration is similar to those found at:
123
141
124
142
pnpm is enabled in the configuration, but a specific version isn't specified as we're using the `packageManager` option in `package.json`.
125
143
126
-
The workflow is configured to run on the `main` branch. You'd typically want the documentation to reflect the latest release, so whether `main` is an appropriate choice will depend on your release process.
144
+
The workflow can be run manually from the **Actions** tab in GitHub. If you opted to [include a workflow for npm publishing](questions#include-npm-publish) then that will also trigger deployment of the docs. This ensures the latest docs are deployed when a new release is published to the npm registry.
127
145
128
-
The [`paths-ignore`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onpushpull_requestpull_request_targetpathspaths-ignore) setting can be used to avoid running GitHub Pages for changes that don't impact the documentation. The default configuration will only ignore the playground package. Trying to be really precise about what changes trigger the workflow is error-prone and the small gains usually aren't worth the extra effort.
146
+
If you want to deploy the docs for all commits to `main` then you'll need to edit `pages.yml` to enable that. The relevant configuration is already included, it's just commented out. This can lead to the docs for new features being released before they're published to npm, so it should only be enabled if it makes sense for your branching strategy and release process.
129
147
130
-
You'll also need to enable GitHub Pages in the settings for your repo.
148
+
### `publish.yml`
149
+
150
+
:::info NOTE
151
+
You'll also need to enable *trusted publishing* in the settings for your package on the npm registry.
152
+
:::
153
+
154
+
The file `.github/worksflows/publish.yml` configures a GitHub workflow to release your package to the npm registry.
155
+
156
+
By default, this workflow will not run automatically. It must be run manually from the **Actions** tab in your GitHub repository. This is intentionally cautious but can easily be changed. A common approach is to tag each release with a git tag and to trigger the workflow whenever a new tag is added to the repo. There's example configuration for that in `publish.yml`.
157
+
158
+
The workflow will build the package and publish it to the npm registry. It avoids building the other packages, such as the docs or playground, and won't run the tests or linting checks. Those checks are already performed by the CI workflow and aren't strictly required to make a release. It is left to your discretion to decide whether your codebase is ready for a release.
159
+
160
+
Running the workflow won't make any changes to the code, such as bumping the version number. You'll need to ensure the version is set correctly in the relevant `package.json` before running the workflow.
0 commit comments