Skip to content

Commit 84130ee

Browse files
committed
fix: add js-yaml dependency and new workflow check for YAML files
1 parent 71390d6 commit 84130ee

5 files changed

Lines changed: 101 additions & 16 deletions

File tree

.github/workflows/auto-version.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,28 +199,48 @@ jobs:
199199
actions: write
200200
steps:
201201
- name: Wait for tag to be available
202-
run: sleep 10
202+
run: sleep 15
203203

204204
- name: Trigger release workflow
205205
uses: actions/github-script@v7
206206
with:
207207
script: |
208208
const version = '${{ needs.auto-version.outputs.new_version }}';
209209
210+
console.log(`🚀 Triggering release workflow for version ${version}`);
211+
210212
try {
211213
await github.rest.actions.createWorkflowDispatch({
212214
owner: context.repo.owner,
213215
repo: context.repo.repo,
214216
workflow_id: 'release.yml',
215217
ref: 'main',
216218
inputs: {
217-
version_type: 'auto',
219+
version_type: 'patch',
218220
force_version: version
219221
}
220222
});
221223
222224
console.log(`✅ Successfully triggered release workflow for version ${version}`);
223225
} catch (error) {
224-
console.log(`⚠️ Failed to trigger release workflow: ${error.message}`);
225-
console.log('This is expected if the release workflow is already running from the tag push');
226+
console.log(`❌ Failed to trigger release workflow: ${error.message}`);
227+
228+
// Try to find if the release workflow is already running
229+
try {
230+
const runs = await github.rest.actions.listWorkflowRuns({
231+
owner: context.repo.owner,
232+
repo: context.repo.repo,
233+
workflow_id: 'release.yml',
234+
status: 'in_progress',
235+
per_page: 5
236+
});
237+
238+
if (runs.data.workflow_runs.length > 0) {
239+
console.log('🔄 Release workflow is already running, skipping trigger');
240+
} else {
241+
console.log('⚠️ No running release workflow found, but trigger failed');
242+
}
243+
} catch (listError) {
244+
console.log('Could not check workflow status');
245+
}
226246
}

.github/workflows/release.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@ jobs:
105105
echo " GitHub: ${GITHUB_VERSION}"
106106
echo " Git: ${GIT_VERSION}"
107107
108-
# Function to compare versions
109-
version_compare() {
110-
printf '%s\n%s\n' "$1" "$2" | sort -V | head -n1
108+
# Function to compare versions (returns 0 if v1 > v2, 1 if v1 <= v2)
109+
version_gt() {
110+
[ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1)" != "$1" ]
111111
}
112112
113-
# Find the highest published version
114-
HIGHEST_VERSION="0.0.0"
115-
for ver in "$NPM_VERSION" "$GITHUB_VERSION" "$GIT_VERSION"; do
116-
if [ "$(version_compare "$HIGHEST_VERSION" "$ver")" = "$HIGHEST_VERSION" ] && [ "$ver" != "$HIGHEST_VERSION" ]; then
117-
HIGHEST_VERSION="$ver"
113+
# Find the highest PUBLISHED version (exclude git tags - they're just markers)
114+
HIGHEST_PUBLISHED="0.0.0"
115+
for ver in "$NPM_VERSION" "$GITHUB_VERSION"; do
116+
if [ "$ver" != "0.0.0" ] && version_gt "$ver" "$HIGHEST_PUBLISHED"; then
117+
HIGHEST_PUBLISHED="$ver"
118118
fi
119119
done
120120
121-
echo "🔍 Highest published version: ${HIGHEST_VERSION}"
121+
echo "🔍 Highest published version: ${HIGHEST_PUBLISHED}"
122122
123123
# Determine version bump type
124124
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.force_version }}" ]; then
@@ -145,7 +145,7 @@ jobs:
145145
fi
146146
147147
# Calculate new version based on highest published version
148-
IFS='.' read -r major minor patch <<< "$HIGHEST_VERSION"
148+
IFS='.' read -r major minor patch <<< "$HIGHEST_PUBLISHED"
149149
case $BUMP_TYPE in
150150
major)
151151
NEW_VERSION="$((major + 1)).0.0"
@@ -164,13 +164,31 @@ jobs:
164164
SHOULD_RELEASE="true"
165165
VERSION_CHANGED="true"
166166
167+
# Check against published versions only (not git tags)
167168
for ver in "$NPM_VERSION" "$GITHUB_VERSION"; do
168-
if [ "$ver" != "0.0.0" ] && [ "$(version_compare "$NEW_VERSION" "$ver")" != "$NEW_VERSION" ]; then
169+
if [ "$ver" != "0.0.0" ] && ! version_gt "$NEW_VERSION" "$ver"; then
169170
echo "❌ New version ${NEW_VERSION} is not higher than published version ${ver}"
170171
SHOULD_RELEASE="false"
171172
fi
172173
done
173174
175+
# Special case: if this is a manual release and the version already exists,
176+
# but we want to republish (e.g., failed previous attempt), allow it
177+
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "$SHOULD_RELEASE" = "false" ]; then
178+
echo "🔄 Manual release mode - checking if we should allow republishing..."
179+
# Allow republishing if the new version equals the highest published version
180+
# but is higher than at least one published source
181+
if [ "$NEW_VERSION" = "$HIGHEST_PUBLISHED" ]; then
182+
for ver in "$NPM_VERSION" "$GITHUB_VERSION"; do
183+
if [ "$ver" != "0.0.0" ] && version_gt "$NEW_VERSION" "$ver"; then
184+
echo "✅ Allowing republish: ${NEW_VERSION} > ${ver}"
185+
SHOULD_RELEASE="true"
186+
break
187+
fi
188+
done
189+
fi
190+
fi
191+
174192
# Check if package.json needs updating
175193
if [ "$PACKAGE_VERSION" = "$NEW_VERSION" ]; then
176194
VERSION_CHANGED="false"

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"prepack": "npm run build",
3636
"test": "echo \"Warning: No tests specified. Please add tests for better CI/CD.\" && exit 0",
3737
"validate": "npm run lint && npm run format:check && npm run type-check && npm run build",
38-
"check-versions": "node scripts/check-versions.js"
38+
"check-versions": "node scripts/check-versions.js",
39+
"check-workflows": "node scripts/check-yaml.js"
3940
},
4041
"files": [
4142
"dist"
@@ -54,6 +55,7 @@
5455
"eslint": "^8.56.0",
5556
"eslint-plugin-n8n-nodes-base": "^1.16.1",
5657
"gulp": "^4.0.2",
58+
"js-yaml": "^4.1.0",
5759
"n8n": "^1.88.0",
5860
"prettier": "^3.3.2",
5961
"typescript": "^5.5.3"

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/check-yaml.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env node
2+
3+
const yaml = require('js-yaml');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
const workflowDir = '.github/workflows';
8+
const files = [
9+
'auto-version.yml',
10+
'release.yml',
11+
'ci.yml'
12+
];
13+
14+
console.log('🔍 Checking YAML syntax...\n');
15+
16+
let allValid = true;
17+
18+
files.forEach(file => {
19+
const filePath = path.join(workflowDir, file);
20+
try {
21+
if (fs.existsSync(filePath)) {
22+
const content = fs.readFileSync(filePath, 'utf8');
23+
yaml.load(content);
24+
console.log(`✅ ${file} - syntax OK`);
25+
} else {
26+
console.log(`⚠️ ${file} - file not found`);
27+
}
28+
} catch (error) {
29+
console.log(`❌ ${file} - syntax error:`);
30+
console.log(` ${error.message}`);
31+
allValid = false;
32+
}
33+
});
34+
35+
console.log('\n' + '='.repeat(40));
36+
if (allValid) {
37+
console.log('🎉 All workflow files have valid YAML syntax!');
38+
process.exit(0);
39+
} else {
40+
console.log('💥 Some workflow files have syntax errors!');
41+
process.exit(1);
42+
}

0 commit comments

Comments
 (0)