httpcat-cli 0.2.8-rc.2 → 0.2.9-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +139 -84
- package/.github/workflows/sync-version.yml +71 -16
- package/package.json +1 -1
|
@@ -132,33 +132,26 @@ jobs:
|
|
|
132
132
|
console.log(`⚠️ Could not compare commits in push (${e.message}), falling back to last release`);
|
|
133
133
|
// Fallback to comparing with last release tag
|
|
134
134
|
if (lastTag) {
|
|
135
|
-
let baseSha;
|
|
136
135
|
try {
|
|
137
|
-
|
|
136
|
+
// Use tag name directly - GitHub API resolves it to commit SHA
|
|
137
|
+
const response = await github.rest.repos.compareCommits({
|
|
138
138
|
owner: context.repo.owner,
|
|
139
139
|
repo: context.repo.repo,
|
|
140
|
-
|
|
140
|
+
base: lastTag,
|
|
141
|
+
head: context.sha
|
|
141
142
|
});
|
|
142
|
-
|
|
143
|
+
compareData = response.data;
|
|
143
144
|
} catch (e2) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
}
|
|
145
|
+
console.log(`⚠️ Tag comparison failed: ${e2.message}, using main branch`);
|
|
146
|
+
// Final fallback to main branch
|
|
147
|
+
const response = await github.rest.repos.compareCommits({
|
|
148
|
+
owner: context.repo.owner,
|
|
149
|
+
repo: context.repo.repo,
|
|
150
|
+
base: 'main',
|
|
151
|
+
head: context.sha
|
|
152
|
+
});
|
|
153
|
+
compareData = response.data;
|
|
154
154
|
}
|
|
155
|
-
const response = await github.rest.repos.compareCommits({
|
|
156
|
-
owner: context.repo.owner,
|
|
157
|
-
repo: context.repo.repo,
|
|
158
|
-
base: baseSha || 'main',
|
|
159
|
-
head: context.sha
|
|
160
|
-
});
|
|
161
|
-
compareData = response.data;
|
|
162
155
|
} else {
|
|
163
156
|
// No last tag and push comparison failed - default to patch
|
|
164
157
|
// We can't reliably determine which commits to analyze without a baseline
|
|
@@ -171,33 +164,25 @@ jobs:
|
|
|
171
164
|
} else if (lastTag) {
|
|
172
165
|
// For other events (like workflow_dispatch), compare with last release
|
|
173
166
|
console.log(`Last release tag: ${lastTag}`);
|
|
174
|
-
let baseSha;
|
|
175
167
|
try {
|
|
176
|
-
|
|
168
|
+
// Use tag name directly - GitHub API resolves it to commit SHA
|
|
169
|
+
const response = await github.rest.repos.compareCommits({
|
|
177
170
|
owner: context.repo.owner,
|
|
178
171
|
repo: context.repo.repo,
|
|
179
|
-
|
|
172
|
+
base: lastTag,
|
|
173
|
+
head: context.sha
|
|
180
174
|
});
|
|
181
|
-
|
|
175
|
+
compareData = response.data;
|
|
182
176
|
} catch (e) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
baseSha = null;
|
|
192
|
-
}
|
|
177
|
+
console.log(`⚠️ Tag comparison failed: ${e.message}, using main branch`);
|
|
178
|
+
const response = await github.rest.repos.compareCommits({
|
|
179
|
+
owner: context.repo.owner,
|
|
180
|
+
repo: context.repo.repo,
|
|
181
|
+
base: 'main',
|
|
182
|
+
head: context.sha
|
|
183
|
+
});
|
|
184
|
+
compareData = response.data;
|
|
193
185
|
}
|
|
194
|
-
const response = await github.rest.repos.compareCommits({
|
|
195
|
-
owner: context.repo.owner,
|
|
196
|
-
repo: context.repo.repo,
|
|
197
|
-
base: baseSha || 'main',
|
|
198
|
-
head: context.sha
|
|
199
|
-
});
|
|
200
|
-
compareData = response.data;
|
|
201
186
|
} else {
|
|
202
187
|
// No last tag and not a push event - default to patch
|
|
203
188
|
// For workflow_dispatch or other events without a tag, we can't reliably
|
|
@@ -337,40 +322,103 @@ jobs:
|
|
|
337
322
|
const currentTag = 'v${{ steps.version.outputs.version }}';
|
|
338
323
|
|
|
339
324
|
// Get commits since last release
|
|
325
|
+
let commits;
|
|
340
326
|
let baseSha;
|
|
341
|
-
|
|
327
|
+
|
|
328
|
+
// For push events, prefer using context.payload.before if available
|
|
329
|
+
// This ensures we only get commits from the current push/merge
|
|
330
|
+
if (context.eventName === 'push' && context.payload.before) {
|
|
331
|
+
console.log(`Using push event comparison (${context.payload.before}..${context.sha})`);
|
|
342
332
|
try {
|
|
343
|
-
const
|
|
333
|
+
const response = await github.rest.repos.compareCommits({
|
|
344
334
|
owner: context.repo.owner,
|
|
345
335
|
repo: context.repo.repo,
|
|
346
|
-
|
|
336
|
+
base: context.payload.before,
|
|
337
|
+
head: context.sha
|
|
347
338
|
});
|
|
348
|
-
|
|
339
|
+
commits = response.data;
|
|
340
|
+
baseSha = context.payload.before;
|
|
341
|
+
console.log(`Found ${commits.commits.length} commits in this push`);
|
|
349
342
|
} catch (e) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
343
|
+
console.log(`⚠️ Push comparison failed: ${e.message}, falling back to tag comparison`);
|
|
344
|
+
// Fall through to tag-based comparison
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// If push comparison didn't work or wasn't available, try tag-based comparison
|
|
349
|
+
if (!commits) {
|
|
350
|
+
if (lastTag) {
|
|
351
|
+
console.log(`Comparing with last tag ${lastTag}`);
|
|
352
|
+
|
|
353
|
+
try {
|
|
354
|
+
// Use the tag name directly - GitHub API will resolve it to the commit SHA
|
|
355
|
+
// This handles both lightweight and annotated tags correctly
|
|
356
|
+
const response = await github.rest.repos.compareCommits({
|
|
357
|
+
owner: context.repo.owner,
|
|
358
|
+
repo: context.repo.repo,
|
|
359
|
+
base: lastTag, // Use tag name directly, API resolves to commit
|
|
360
|
+
head: context.sha
|
|
361
|
+
});
|
|
362
|
+
commits = response.data;
|
|
363
|
+
baseSha = lastTag; // Store tag name for changelog link
|
|
364
|
+
console.log(`Found ${commits.commits.length} commits since ${lastTag}`);
|
|
365
|
+
} catch (e) {
|
|
366
|
+
console.log(`⚠️ Tag comparison failed: ${e.message}`);
|
|
367
|
+
console.log(`Error details: ${e.response?.data?.message || e.message}`);
|
|
368
|
+
|
|
369
|
+
// Try to get the actual commit SHA from the tag as fallback
|
|
370
|
+
try {
|
|
371
|
+
const { data: commitData } = await github.rest.repos.getCommit({
|
|
372
|
+
owner: context.repo.owner,
|
|
373
|
+
repo: context.repo.repo,
|
|
374
|
+
ref: lastTag
|
|
375
|
+
});
|
|
376
|
+
const tagCommitSha = commitData.sha;
|
|
377
|
+
console.log(`Resolved tag ${lastTag} to commit ${tagCommitSha}, retrying comparison...`);
|
|
378
|
+
|
|
379
|
+
const response = await github.rest.repos.compareCommits({
|
|
380
|
+
owner: context.repo.owner,
|
|
381
|
+
repo: context.repo.repo,
|
|
382
|
+
base: tagCommitSha,
|
|
383
|
+
head: context.sha
|
|
384
|
+
});
|
|
385
|
+
commits = response.data;
|
|
386
|
+
baseSha = tagCommitSha;
|
|
387
|
+
console.log(`Found ${commits.commits.length} commits since ${lastTag}`);
|
|
388
|
+
} catch (e2) {
|
|
389
|
+
console.log(`⚠️ Commit SHA comparison also failed: ${e2.message}`);
|
|
390
|
+
// Fall through to main branch comparison
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// If tag comparison failed or no tag exists, compare with main branch
|
|
396
|
+
if (!commits) {
|
|
397
|
+
try {
|
|
398
|
+
const { data: branchData } = await github.rest.repos.getBranch({
|
|
399
|
+
owner: context.repo.owner,
|
|
400
|
+
repo: context.repo.repo,
|
|
401
|
+
branch: 'main'
|
|
402
|
+
});
|
|
403
|
+
baseSha = branchData.commit.sha;
|
|
404
|
+
console.log(`Comparing with main branch (${baseSha})`);
|
|
405
|
+
|
|
406
|
+
const response = await github.rest.repos.compareCommits({
|
|
407
|
+
owner: context.repo.owner,
|
|
408
|
+
repo: context.repo.repo,
|
|
409
|
+
base: baseSha,
|
|
410
|
+
head: context.sha
|
|
411
|
+
});
|
|
412
|
+
commits = response.data;
|
|
413
|
+
console.log(`Found ${commits.commits.length} commits since main branch HEAD`);
|
|
414
|
+
} catch (e) {
|
|
415
|
+
console.log(`⚠️ Main branch comparison also failed: ${e.message}`);
|
|
416
|
+
console.log(`Using empty commit list - release notes will be minimal`);
|
|
417
|
+
commits = { commits: [] };
|
|
418
|
+
baseSha = null;
|
|
419
|
+
}
|
|
357
420
|
}
|
|
358
|
-
} else {
|
|
359
|
-
// Get the first commit or main branch
|
|
360
|
-
const { data: branchData } = await github.rest.repos.getBranch({
|
|
361
|
-
owner: context.repo.owner,
|
|
362
|
-
repo: context.repo.repo,
|
|
363
|
-
branch: 'main'
|
|
364
|
-
});
|
|
365
|
-
baseSha = branchData.commit.sha;
|
|
366
421
|
}
|
|
367
|
-
|
|
368
|
-
const { data: commits } = await github.rest.repos.compareCommits({
|
|
369
|
-
owner: context.repo.owner,
|
|
370
|
-
repo: context.repo.repo,
|
|
371
|
-
base: baseSha,
|
|
372
|
-
head: context.sha
|
|
373
|
-
});
|
|
374
422
|
|
|
375
423
|
// Categorize commits
|
|
376
424
|
const features = [];
|
|
@@ -379,21 +427,25 @@ jobs:
|
|
|
379
427
|
const chore = [];
|
|
380
428
|
const breaking = [];
|
|
381
429
|
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
430
|
+
if (commits && commits.commits && commits.commits.length > 0) {
|
|
431
|
+
for (const commit of commits.commits) {
|
|
432
|
+
const message = commit.commit.message;
|
|
433
|
+
const firstLine = message.split('\n')[0];
|
|
434
|
+
|
|
435
|
+
if (firstLine.match(/^BREAKING/)) {
|
|
436
|
+
breaking.push(`- ${firstLine.replace(/^BREAKING[:\s]+/i, '')}`);
|
|
437
|
+
} else if (firstLine.match(/^feat(ure)?[(:]/i)) {
|
|
438
|
+
features.push(`- ${firstLine.replace(/^feat(ure)?[(:]\s*/i, '')}`);
|
|
439
|
+
} else if (firstLine.match(/^fix[(]/i)) {
|
|
440
|
+
fixes.push(`- ${firstLine.replace(/^fix[(]\s*/i, '')}`);
|
|
441
|
+
} else if (firstLine.match(/^doc(s)?[(]/i)) {
|
|
442
|
+
docs.push(`- ${firstLine.replace(/^doc(s)?[(]\s*/i, '')}`);
|
|
443
|
+
} else if (!firstLine.match(/^(chore|ci|test|build)[(:]/i)) {
|
|
444
|
+
chore.push(`- ${firstLine}`);
|
|
445
|
+
}
|
|
396
446
|
}
|
|
447
|
+
} else {
|
|
448
|
+
console.log('⚠️ No commits found for release notes - using minimal release notes');
|
|
397
449
|
}
|
|
398
450
|
|
|
399
451
|
let notes = `## 🎉 Release ${{ steps.version.outputs.version }}\n\n`;
|
|
@@ -426,10 +478,13 @@ jobs:
|
|
|
426
478
|
notes += `brew upgrade httpcat\n`;
|
|
427
479
|
notes += `\`\`\`\n\n`;
|
|
428
480
|
notes += `---\n\n`;
|
|
429
|
-
|
|
481
|
+
|
|
482
|
+
// Generate changelog link - use lastTag if available, otherwise use main
|
|
483
|
+
const changelogBase = lastTag || 'main';
|
|
484
|
+
notes += `**Full Changelog**: https://github.com/${{ github.repository }}/compare/${changelogBase}...${currentTag}`;
|
|
430
485
|
|
|
431
486
|
core.setOutput('notes', notes);
|
|
432
|
-
console.log('Generated release notes');
|
|
487
|
+
console.log('✅ Generated release notes');
|
|
433
488
|
|
|
434
489
|
# Job 2: Build and test
|
|
435
490
|
test:
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
name: Sync Version to Develop
|
|
2
2
|
|
|
3
|
-
# This workflow runs after a release to
|
|
3
|
+
# This workflow runs after a release to reset develop to match main and sync the version
|
|
4
4
|
on:
|
|
5
5
|
release:
|
|
6
6
|
types: [published]
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
sync-version:
|
|
10
|
-
name:
|
|
10
|
+
name: Reset develop to match main
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
permissions:
|
|
13
13
|
contents: write
|
|
@@ -25,32 +25,87 @@ jobs:
|
|
|
25
25
|
# Remove 'v' prefix if present
|
|
26
26
|
VERSION="${VERSION#v}"
|
|
27
27
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
28
|
-
echo "✅ Version
|
|
28
|
+
echo "✅ Version from release: $VERSION"
|
|
29
29
|
|
|
30
30
|
- name: Checkout develop branch
|
|
31
31
|
run: |
|
|
32
32
|
git checkout develop
|
|
33
33
|
git pull origin develop
|
|
34
34
|
|
|
35
|
-
- name:
|
|
35
|
+
- name: Check for new commits in develop
|
|
36
|
+
id: check-commits
|
|
36
37
|
run: |
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
echo "
|
|
38
|
+
# Check if develop has commits that aren't in main
|
|
39
|
+
COMMITS_AHEAD=$(git rev-list --count origin/main..HEAD 2>/dev/null || echo "0")
|
|
40
|
+
echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT
|
|
41
|
+
|
|
42
|
+
if [ "$COMMITS_AHEAD" -gt 0 ]; then
|
|
43
|
+
echo "ℹ️ Develop has $COMMITS_AHEAD commit(s) not in main"
|
|
44
|
+
echo "These will be preserved by rebasing onto main"
|
|
45
|
+
else
|
|
46
|
+
echo "✅ Develop has no new commits - can fast-forward to main"
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
- name: Rebase develop onto main
|
|
50
|
+
run: |
|
|
51
|
+
echo "Updating develop to include latest from main..."
|
|
52
|
+
git fetch origin main
|
|
53
|
+
|
|
54
|
+
# Check if we can fast-forward (no new commits in develop)
|
|
55
|
+
COMMITS_AHEAD="${{ steps.check-commits.outputs.commits_ahead }}"
|
|
56
|
+
|
|
57
|
+
if [ "$COMMITS_AHEAD" -eq 0 ]; then
|
|
58
|
+
# Fast-forward: just move develop to main
|
|
59
|
+
echo "Fast-forwarding develop to main..."
|
|
60
|
+
git reset --hard origin/main
|
|
61
|
+
else
|
|
62
|
+
# Rebase: replay develop's commits on top of main
|
|
63
|
+
echo "Rebasing develop onto main..."
|
|
64
|
+
git rebase origin/main || {
|
|
65
|
+
echo "⚠️ Rebase conflict detected - this shouldn't happen if develop was properly merged"
|
|
66
|
+
echo "Falling back to reset (this will discard develop-only commits)"
|
|
67
|
+
git rebase --abort 2>/dev/null || true
|
|
68
|
+
git reset --hard origin/main
|
|
69
|
+
}
|
|
70
|
+
fi
|
|
71
|
+
echo "✅ Develop updated to include latest from main"
|
|
72
|
+
|
|
73
|
+
- name: Verify package.json version
|
|
74
|
+
run: |
|
|
75
|
+
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
76
|
+
RELEASE_VERSION="${{ steps.version.outputs.version }}"
|
|
77
|
+
|
|
78
|
+
echo "Current version in package.json: $CURRENT_VERSION"
|
|
79
|
+
echo "Release version: $RELEASE_VERSION"
|
|
80
|
+
|
|
81
|
+
if [ "$CURRENT_VERSION" != "$RELEASE_VERSION" ]; then
|
|
82
|
+
echo "Updating package.json version..."
|
|
83
|
+
npm version "$RELEASE_VERSION" --no-git-tag-version --allow-same-version
|
|
84
|
+
git add package.json
|
|
85
|
+
git commit -m "chore: sync version to $RELEASE_VERSION" || echo "No changes to commit"
|
|
86
|
+
else
|
|
87
|
+
echo "✅ Version already matches"
|
|
88
|
+
fi
|
|
40
89
|
|
|
41
|
-
- name:
|
|
90
|
+
- name: Push to develop
|
|
42
91
|
run: |
|
|
43
|
-
VERSION="${{ steps.version.outputs.version }}"
|
|
44
92
|
git config user.name "github-actions[bot]"
|
|
45
93
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
46
|
-
git add package.json
|
|
47
94
|
|
|
48
|
-
# Check if there are changes to
|
|
49
|
-
if git diff --
|
|
50
|
-
echo "✅
|
|
95
|
+
# Check if there are any changes to push
|
|
96
|
+
if git diff --quiet origin/develop HEAD; then
|
|
97
|
+
echo "✅ No changes to push (develop already up to date)"
|
|
51
98
|
else
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
99
|
+
COMMITS_AHEAD="${{ steps.check-commits.outputs.commits_ahead }}"
|
|
100
|
+
if [ "$COMMITS_AHEAD" -eq 0 ]; then
|
|
101
|
+
# Fast-forward push (no force needed)
|
|
102
|
+
echo "Pushing fast-forward update..."
|
|
103
|
+
git push origin develop
|
|
104
|
+
else
|
|
105
|
+
# Rebase requires force push (but this is safe after rebase)
|
|
106
|
+
echo "Pushing rebased develop branch..."
|
|
107
|
+
git push origin develop --force-with-lease
|
|
108
|
+
fi
|
|
109
|
+
echo "✅ Develop updated and pushed"
|
|
55
110
|
fi
|
|
56
111
|
|