Repository navigation
141 lines (121 loc) · 5.33 KB
/
Copy pathguidechimp-release.yml
File metadata and controls
141 lines (121 loc) · 5.33 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: GuideChimp - Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 3.2.1) or bump type (patch, minor, major)'
required: true
default: 'patch'
release_notes:
description: 'Release notes — leave blank to auto-generate from commits/PRs'
required: false
type: string
permissions:
contents: write
packages: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
environment: npm-publish
steps:
# ── Checkout Repositories ───────────────────────────────────────────────
- name: Checkout GuideChimp
uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Read Plugins version from package.json
id: plugins_version
run: |
# Replaces the outdated notiz-dev 3rd-party action with a fast native script
PLUGINS_VER=$(node -p "require('./package.json').plugins['guidechimp-plugins']")
echo "version=$PLUGINS_VER" >> $GITHUB_OUTPUT
echo "✅ Found plugin version: $PLUGINS_VER"
- name: Checkout GuideChimp Plugins (v${{ steps.plugins_version.outputs.version }})
uses: actions/checkout@v5
with:
repository: Labs64/GuideChimp-plugins
path: guidechimp-plugins
ref: ${{ steps.plugins_version.outputs.version }}
token: ${{ secrets.GUIDECHIMP_PAT }}
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 20
cache: npm
registry-url: https://registry.npmjs.org/
# ── Guards ──────────────────────────────────────────────────────────────
- name: Validate version input
run: |
INPUT="${{ inputs.version }}"
if echo "$INPUT" | grep -Pq '^(patch|minor|major)$'; then
echo "✅ Bump type: $INPUT"
elif echo "$INPUT" | grep -Pq '^\d+\.\d+\.\d+(-[\w.]+)?(\+[\w.]+)?$'; then
echo "✅ Explicit version: $INPUT"
else
echo "❌ '$INPUT' is neither a bump type (patch/minor/major) nor valid semver"
exit 1
fi
- name: Check version not already tagged
run: |
INPUT="${{ inputs.version }}"
if echo "$INPUT" | grep -Pq '^\d+'; then
if git ls-remote --tags origin | grep -q "refs/tags/${INPUT}$"; then
echo "❌ Tag ${INPUT} already exists — bump the version or delete the tag first"
exit 1
fi
fi
# ── Install & Test GuideChimp ───────────────────────────────────────────
- name: Install dependencies
run: npm ci
- name: Check outdated dependencies
run: npm outdated || true
- name: Run tests
env:
GUIDECHIMP_PRIVATE_KEY: ${{ secrets.GUIDECHIMP_PRIVATE_KEY }}
GUIDECHIMP_PUBLIC_KEY: ${{ secrets.GUIDECHIMP_PUBLIC_KEY }}
run: npm run test
# ── Git: configure and bump version before build ──────────────────────
- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Bump version and tag
id: bump
run: |
npm version ${{ inputs.version }} --tag-version-prefix="" -m "Release %s"
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
git push --follow-tags
# ── Build Core & Plugins ────────────────────────────────────────────────
# ensure the dist directory is completely fresh before building anything
- name: Clean existing dist
run: |
echo "Removing any leftover files from previous releases"
rm -rf dist/* || true
- name: Build GuideChimp Core
run: npm run build --if-present
- name: Build GuideChimp Plugins
working-directory: ./guidechimp-plugins
run: |
npm ci
npm run build --if-present
- name: Sync Plugins to GuideChimp dist
run: |
mkdir -p dist/plugins
rsync -av guidechimp-plugins/dist/ dist/plugins/
ls -la -R dist/
# ── Publish ─────────────────────────────────────────────────────────────
- name: Update npm
run: npm install -g npm@latest
- name: Publish to npm
run: npm publish --provenance --access public
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.bump.outputs.new_version }}
name: ${{ steps.bump.outputs.new_version }}
body: ${{ inputs.release_notes }}
generate_release_notes: ${{ inputs.release_notes == '' }}
files: dist/**