Skip to content

Commit c830361

Browse files
authored
chore(CI): Create workflow to release to NPM (#40)
1 parent 5a72a2d commit c830361

File tree

5 files changed

+122
-2
lines changed

5 files changed

+122
-2
lines changed

.github/workflows/npm-publish.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish to NPM
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [created]
7+
8+
jobs:
9+
publish-npm:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 20
16+
registry-url: https://registry.npmjs.org/
17+
- run: yarn install
18+
- run: yarn dev:build
19+
- run: yarn publish
20+
env:
21+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.2.4
4+
5+
[compare changes](https://github.com/stackbuilders/nuxt-utm/compare/v0.2.3...v0.2.4)
6+
37
## v0.2.2
48

59
[compare changes](https://github.com/stackbuilders/nuxt-utm/compare/v0.1.5...v0.2.2)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ yarn test:watch
140140
yarn release
141141
```
142142

143+
For detailed information about the release process, please refer to our [Release Documentation](/docs/RELEASING.md).
144+
143145
## License
144146

145147
<!-- NOTE: If you need a different type of licence, please check with the OSS team before changing it -->

docs/RELEASING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Release Process
2+
3+
This document outlines the release process for the Nuxt UTM module.
4+
5+
## Release Workflow
6+
7+
We follow a two-step release process:
8+
9+
1. **Manual Release Preparation (Local)**:
10+
11+
- Version bump
12+
- CHANGELOG update
13+
- Tag creation
14+
- Git commit
15+
16+
2. **Automated NPM Publishing (GitHub Actions)**:
17+
- Triggered by the newly created release/tag
18+
- Builds and publishes the package to NPM
19+
20+
## Manual Release Steps
21+
22+
To create a new release:
23+
24+
1. Ensure you have the latest changes from the main branch:
25+
26+
```bash
27+
git checkout main
28+
git pull origin main
29+
```
30+
31+
2. Make sure all tests pass:
32+
33+
```bash
34+
yarn test
35+
```
36+
37+
3. Run the release script, which will:
38+
39+
- Bump the version in package.json
40+
- Update the CHANGELOG.md
41+
- Create a git tag
42+
- Commit changes
43+
44+
```bash
45+
yarn release
46+
```
47+
48+
4. Push the changes including the new tag:
49+
```bash
50+
# This will be done automatically by the release script
51+
```
52+
53+
## Automated NPM Publishing
54+
55+
After the manual release process:
56+
57+
1. GitHub Actions workflow [npm-publish.yml](../.github/workflows/npm-publish.yml) will be triggered automatically when:
58+
59+
- A new GitHub release is created
60+
- OR manually triggered via workflow_dispatch
61+
62+
2. The workflow will:
63+
- Check out the repository
64+
- Set up Node.js
65+
- Install dependencies
66+
- Build the module
67+
- Publish to NPM using the credentials stored in GitHub secrets
68+
69+
## Version Numbering
70+
71+
We follow [Semantic Versioning](https://semver.org/) for this project:
72+
73+
- **MAJOR** version for incompatible API changes
74+
- **MINOR** version for backwards-compatible functionality additions
75+
- **PATCH** version for backwards-compatible bug fixes
76+
77+
## Troubleshooting
78+
79+
If the automated publishing fails:
80+
81+
1. Check the GitHub Actions logs for errors
82+
2. Ensure the `npm_token` secret is correctly set in the repository settings
83+
3. Verify that the version in package.json hasn't already been published
84+
85+
## Additional Notes
86+
87+
- The release process uses [changelogen](https://github.com/unjs/changelogen) to generate CHANGELOG entries
88+
- Always verify that the published package works correctly by installing it in a test project
89+
90+
---
91+
92+
For questions or assistance with the release process, please contact the maintainers or email [[email protected]](mailto:[email protected]).

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuxt-utm",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "A Nuxt 3 module for tracking UTM parameters.",
55
"keywords": [
66
"nuxt",
@@ -39,7 +39,8 @@
3939
"dev": "nuxi dev playground",
4040
"dev:build": "nuxi build playground",
4141
"dev:prepare": "nuxt-module-build --stub && nuxt-module-build prepare && nuxi prepare playground",
42-
"release": "npm run prepack && changelogen --release && npm publish && git push --follow-tags",
42+
"release": "npm run prepack && changelogen --release && git push --follow-tags",
43+
"publish": "npm run prepack && npm publish",
4344
"lint": "eslint .",
4445
"test": "vitest run",
4546
"test:watch": "vitest watch"

0 commit comments

Comments
 (0)