-
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (113 loc) · 4.16 KB
/
release.yml
File metadata and controls
133 lines (113 loc) · 4.16 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
test:
name: Test before release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Verify release version
run: |
PACKAGE_VERSION=$(node -p "require('./packages/cli/package.json').version")
LOCK_VERSION=$(node -p "require('./package-lock.json').packages['packages/cli'].version")
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "Tag version ($TAG_VERSION) must match packages/cli/package.json ($PACKAGE_VERSION)." >&2
exit 1
fi
if [ "$LOCK_VERSION" != "$PACKAGE_VERSION" ]; then
echo "package-lock.json packages/cli version ($LOCK_VERSION) must match packages/cli/package.json ($PACKAGE_VERSION)." >&2
exit 1
fi
- run: npm ci
- run: npm -w packages/cli run lint
- run: npm -w packages/cli run build
- run: npm -w packages/cli test
release:
name: Create release
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
uses: orhun/git-cliff-action@v4
with:
config: .github/cliff.toml
args: --latest --strip header
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.content }}
draft: false
prerelease: false
- name: Update major version tag
run: |
VERSION=${{ github.ref_name }}
MAJOR=$(echo "$VERSION" | grep -oE '^v[0-9]+')
git tag -f "$MAJOR"
git push origin "$MAJOR" -f
publish:
name: Publish to npm
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://registry.npmjs.org
cache: npm
- run: npm ci
- run: npm -w packages/cli run build
- name: Publish canonical package
run: |
PACKAGE_VERSION=$(node -p "require('./packages/cli/package.json').version")
if npm view "agent-note@$PACKAGE_VERSION" version >/dev/null 2>&1; then
echo "agent-note@$PACKAGE_VERSION is already published; skipping canonical publish."
exit 0
fi
npm -w packages/cli publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish reserved alias package
run: |
PACKAGE_VERSION=$(node -p "require('./packages/cli/package.json').version")
ALIAS_PACKAGE="@wasabeef/agentnote"
if npm view "$ALIAS_PACKAGE@$PACKAGE_VERSION" version >/dev/null 2>&1; then
echo "$ALIAS_PACKAGE@$PACKAGE_VERSION is already published; skipping alias publish."
exit 0
fi
ALIAS_DIR=$(mktemp -d)
cp packages/cli/package.json "$ALIAS_DIR/package.json"
cp -R packages/cli/dist "$ALIAS_DIR/dist"
ALIAS_DIR="$ALIAS_DIR" ALIAS_PACKAGE="$ALIAS_PACKAGE" node <<'NODE'
const fs = require("node:fs");
const path = require("node:path");
const packagePath = path.join(process.env.ALIAS_DIR, "package.json");
const pkg = JSON.parse(fs.readFileSync(packagePath, "utf8"));
pkg.name = process.env.ALIAS_PACKAGE;
pkg.bin = { agentnote: "dist/cli.js" };
pkg.keywords = Array.from(new Set([...(pkg.keywords || []), "agentnote"]));
pkg.repository = {
...pkg.repository,
url: "git+https://github.com/wasabeef/AgentNote.git",
};
fs.writeFileSync(packagePath, `${JSON.stringify(pkg, null, 2)}\n`);
NODE
npm publish "$ALIAS_DIR" --access public --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}