Skip to content

Commit 00d84ef

Browse files
committed
ci(other): 👷 refine changelog retrieval logic, enhance release workflow, and update file handling in GitHub Actions
1 parent 6b1742b commit 00d84ef

File tree

2 files changed

+50
-53
lines changed

2 files changed

+50
-53
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,52 @@ jobs:
1717
contents: write
1818
pull-requests: write
1919

20+
steps:
21+
# 🧩 Checkout full repository (with history)
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
2026

21-
steps: # 🧩 Checkout full repository (with history)
22-
- name: Checkout repository
23-
uses: actions/checkout@v4
24-
with:
25-
fetch-depth: 0
27+
# 🧰 Setup Node + pnpm environment
28+
- name: Setup Node.js 20
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: "pnpm"
33+
registry-url: 'https://registry.npmjs.org'
2634

27-
# 🧰 Setup Node + pnpm environment
28-
- name: Setup Node.js 20
29-
uses: actions/setup-node@v4
30-
with:
31-
node-version: 20
32-
cache: "pnpm"
33-
registry-url: 'https://registry.npmjs.org'
35+
- name: Generate changelog
36+
run: npx githublogen
37+
env:
38+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
3439

35-
- name: Generate changelog
40+
- name: Setup pnpm
41+
uses: pnpm/action-setup@v4
42+
with:
43+
version: 9.0.6
3644

37-
run: npx githublogen
38-
env:
39-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
45+
# 📦 Install dependencies
46+
- name: Install dependencies
47+
run: pnpm install --frozen-lockfile
4048

41-
- name: Setup pnpm
42-
uses: pnpm/action-setup@v4
43-
with:
44-
version: 9.0.6
45-
46-
# 📦 Install dependencies
47-
- name: Install dependencies
48-
run: pnpm install --frozen-lockfile
49-
50-
# 📦 Extract package name from tag
51-
- name: Extract package name from tag
52-
id: package
53-
run: |
54-
TAG_NAME="${GITHUB_REF#refs/tags/}"
55-
PACKAGE_NAME="${TAG_NAME%@*}"
56-
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
57-
echo "Building package: $PACKAGE_NAME"
58-
shell: bash
59-
60-
# 🏗️ Build package
61-
- name: Build package
62-
run: pnpm --filter ${{ steps.package.outputs.name }} build
63-
shell: bash
64-
65-
# 🏷️ Publish to npm
66-
- name: Publish to npm
67-
run: pnpm --filter ${{ steps.package.outputs.name }} publish --access public --no-git-checks
68-
env:
69-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
# 📦 Extract package name from tag
50+
- name: Extract package name from tag
51+
id: package
52+
run: |
53+
TAG_NAME="${GITHUB_REF#refs/tags/}"
54+
PACKAGE_NAME="${TAG_NAME%@*}"
55+
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
56+
echo "Building package: $PACKAGE_NAME"
57+
shell: bash
7058

59+
# 🏗️ Build package
60+
- name: Build package
61+
run: pnpm --filter ${{ steps.package.outputs.name }} build
62+
shell: bash
7163

64+
# 🏷️ Publish to npm
65+
- name: Publish to npm
66+
run: pnpm --filter ${{ steps.package.outputs.name }} publish --access public --no-git-checks
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

skyroc.config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import path from 'node:path';
55
import { defineConfig } from '@skyroc/cli';
66

77
function getLastTag() {
8-
const tag = execSync('git tag -l --sort=v:refname | tail -n 1').toString().trim();
8+
const tag = execSync('git tag -l ').toString().split('\n');
99

10-
return tag;
10+
return tag.at(-2);
1111
}
1212

13-
getLastTag();
14-
1513
export default defineConfig({
1614
changelogOptions: {
1715
from: getLastTag()
@@ -52,6 +50,8 @@ export default defineConfig({
5250
process.exit(1);
5351
}
5452

53+
console.log('pkgPath', pkgPath);
54+
5555
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
5656

5757
const current = pkg.version;
@@ -64,7 +64,6 @@ export default defineConfig({
6464
return {
6565
commit: `chore(${pkgName}): release v%s`,
6666
confirm: false,
67-
cwd,
6867
// Use function to access op.state.newVersion and pass it to changelog command
6968
execute: async op => {
7069
const { execSync: execSync2 } = await import('node:child_process');
@@ -78,16 +77,17 @@ export default defineConfig({
7877
env: { ...process.env, CHANGELOG_TAG: tag },
7978
stdio: 'inherit'
8079
});
80+
81+
// Add CHANGELOG.md to git staging area
8182
},
82-
files: ['**/package.json', '!**/node_modules'],
83+
files: [pkgPath, './CHANGELOG.md'],
8384
preid,
8485
progress(info) {
85-
// Log release progress events
8686
// eslint-disable-next-line no-console
8787
console.log(`[${info.event}] ${info.newVersion ?? ''} ${info.commit ?? ''}`);
8888
},
8989
// Automatic commit type analysis
90-
push: false,
90+
push: true,
9191
release,
9292
tag: `${pkgName}@%s`
9393
};

0 commit comments

Comments
 (0)