This repository was archived by the owner on May 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
109 lines (89 loc) · 2.72 KB
/
Copy pathrelease.yml
File metadata and controls
109 lines (89 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v5
with:
node-version: 22.x
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1
- name: Check version match
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
PACKAGE_VERSION="${{ steps.package.outputs.version }}"
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
exit 1
fi
echo "✅ Version in package.json matches GitHub tag"
test:
runs-on: ubuntu-latest
needs: verify
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v5
with:
node-version: 22.x
- name: Install dependencies
run: npm install
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Run tests
run: npm test || echo "No tests found, skipping test step"
publish:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v5
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v4.1.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
body: |
${{ steps.changelog.outputs.changelog }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}...HEAD
draft: false
prerelease: false
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Notify success
uses: rjstone/discord-webhook-notify@v1
if: success()
with:
severity: info
details: |
Version ${{ github.ref_name }} has been successfully published to NPM! 🎉
See the release here: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
continue-on-error: true