Skip to content

Commit 9b8139a

Browse files
authored
ci(release): add npm publish command (#16)
1 parent b15e30b commit 9b8139a

2 files changed

Lines changed: 32 additions & 36 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,33 @@ on:
77
required: true
88
type: choice
99
description: Which version should be published?
10-
options:
11-
- patch
12-
- minor
13-
- major
14-
- prepatch
15-
- preminor
16-
- premajor
17-
- prerelease
10+
options: [patch, minor, major, prepatch, preminor, premajor, prerelease]
1811
tag:
1912
required: true
2013
type: choice
2114
description: Which npm tag should this be published to?
22-
options:
23-
- latest
24-
- next
15+
options: [latest, next]
2516

2617
jobs:
2718
create-release:
2819
runs-on: ubuntu-latest
20+
environment: npm-publish
21+
permissions:
22+
contents: write
23+
id-token: write
2924
steps:
25+
- name: Generate Token
26+
uses: actions/create-github-app-token@v1
27+
id: app-token
28+
with:
29+
app-id: ${{ secrets.BOT_APP_ID }}
30+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
31+
3032
- name: Checkout
3133
uses: actions/checkout@v4
34+
with:
35+
token: ${{ steps.app-token.outputs.token }}
36+
fetch-depth: 0
3237

3338
- name: Configure Git Identity
3439
run: |
@@ -38,12 +43,21 @@ jobs:
3843
- name: Setup
3944
uses: ./.github/actions/setup
4045

41-
- name: Install changelogen
42-
run: pnpm add -g changelogen
46+
- name: Ensure Latest NPM
47+
run: npm install -g npm@latest
48+
49+
- name: Bump Version and Push
50+
env:
51+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
52+
run: |
53+
PRERELEASE_FLAG=""
54+
if [[ "${{ github.event.inputs.version }}" == pre* ]]; then PRERELEASE_FLAG="--prerelease"; fi
55+
pnpm dlx changelogen@latest --bump --release $PRERELEASE_FLAG --${{ github.event.inputs.version }} --push
56+
57+
- name: Build
58+
run: pnpm run build
4359

44-
- name: Create new version
45-
id: version
60+
- name: Publish to NPM
4661
run: |
47-
pnpm config set //registry.npmjs.org/:_authToken ""
48-
pnpm dlx changelogen --bump --release --${{ github.event.inputs.version }} --publishTag ${{ github.event.inputs.tag }} --push --publish
49-
pnpm dlx changelogen gh release
62+
npm config set //registry.npmjs.org/:_authToken ""
63+
npm publish --provenance --access public --tag ${{ github.event.inputs.tag }}

CHANGELOG.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
11
# Changelog
2-
3-
## v0.0.3-0
4-
5-
6-
### 🤖 CI
7-
8-
- **release:** Trigger new create release workflow and bump version ([#15](https://github.com/ambitiondev/dynamic-url/pull/15))
9-
10-
### ❤️ Contributors
11-
12-
- Berrie Nachtweh ([@bnachtweh](https://github.com/bnachtweh))
13-
14-
## [0.0.2](https://github.com/ambitiondev/dynamic-url/compare/dynamic-url-v0.0.1...dynamic-url-v0.0.2) (2026-01-15)
15-
16-
17-
### Bug Fixes
18-
19-
* **release:** make sure the release gets done following v4 ([#9](https://github.com/ambitiondev/dynamic-url/issues/9)) ([9b156a2](https://github.com/ambitiondev/dynamic-url/commit/9b156a2d40399e46663f0edf6c5ab6526bf0482d))

0 commit comments

Comments
 (0)