-
Notifications
You must be signed in to change notification settings - Fork 40
89 lines (74 loc) · 2.76 KB
/
publish.yml
File metadata and controls
89 lines (74 loc) · 2.76 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
name: Publish to npm
on:
push:
branches: [main]
paths:
- 'package.json'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- name: Check if version changed
id: version
run: |
# Get the version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Check if this version exists on npm
if npm view @masonator/coolify-mcp@$CURRENT_VERSION version 2>/dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.version.outputs.exists == 'false'
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
if: steps.version.outputs.exists == 'false'
run: npm ci
- name: Run tests
if: steps.version.outputs.exists == 'false'
run: npm test
- name: Build
if: steps.version.outputs.exists == 'false'
run: npm run build
- name: Publish to npm
if: steps.version.outputs.exists == 'false'
run: npm publish --access public
- name: Extract changelog for version
if: steps.version.outputs.exists == 'false'
id: changelog
run: |
VERSION="${{ steps.version.outputs.current }}"
# Extract the section for this version from CHANGELOG.md
# Matches from ## [version] until the next ## [ or end of file
NOTES=$(awk "/^## \\[$VERSION\\]/{flag=1; next} /^## \\[/{flag=0} flag" CHANGELOG.md)
# Handle multi-line output for GitHub Actions
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
if: steps.version.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.current }}
name: v${{ steps.version.outputs.current }}
body: |
## What's Changed
${{ steps.changelog.outputs.notes }}
---
📦 [View on npm](https://www.npmjs.com/package/@masonator/coolify-mcp/v/${{ steps.version.outputs.current }})
draft: false
prerelease: false
generate_release_notes: false
- name: Skip publish (version exists)
if: steps.version.outputs.exists == 'true'
run: echo "Version ${{ steps.version.outputs.current }} already exists on npm, skipping publish"