mirror of
https://github.com/ichaly/cohere.git
synced 2026-07-22 07:47:20 +00:00
Add GitHub release workflow
This commit is contained in:
parent
b7da3ae957
commit
2418195b1a
4 changed files with 119 additions and 0 deletions
57
.github/workflows/release.yml
vendored
Normal file
57
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.33.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Validate release files
|
||||
run: pnpm run release:check
|
||||
|
||||
- name: Stage release assets
|
||||
run: |
|
||||
mkdir -p release
|
||||
cp manifest.json release/manifest.json
|
||||
cp dist/main.js release/main.js
|
||||
cp dist/main.css release/styles.css
|
||||
|
||||
- name: Publish GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
release/manifest.json
|
||||
release/main.js
|
||||
release/styles.css
|
||||
|
||||
24
README.md
24
README.md
|
|
@ -76,3 +76,27 @@ pnpm install-plugin "/path/to/your-vault"
|
|||
```text
|
||||
obsync
|
||||
```
|
||||
|
||||
## 发布
|
||||
|
||||
推送版本 tag 会触发 GitHub Actions 自动发布:
|
||||
|
||||
```bash
|
||||
git tag v0.1.0
|
||||
git push origin v0.1.0
|
||||
```
|
||||
|
||||
Release 会上传:
|
||||
|
||||
```text
|
||||
manifest.json
|
||||
main.js
|
||||
styles.css
|
||||
```
|
||||
|
||||
发布前可以本地检查:
|
||||
|
||||
```bash
|
||||
pnpm run build
|
||||
pnpm run release:check
|
||||
```
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"dev": "vite build --watch",
|
||||
"build": "tsc --noEmit --skipLibCheck && vite build",
|
||||
"install-plugin": "node scripts/install-plugin.mjs",
|
||||
"release:check": "node scripts/check-release.mjs",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"keywords": [
|
||||
|
|
|
|||
37
scripts/check-release.mjs
Normal file
37
scripts/check-release.mjs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { existsSync, readFileSync } from "node:fs";
|
||||
|
||||
const packageJson = readJson("package.json");
|
||||
const manifest = readJson("manifest.json");
|
||||
const versions = readJson("versions.json");
|
||||
const tag = process.env.GITHUB_REF_NAME ?? "";
|
||||
const normalizedTag = tag.startsWith("v") ? tag.slice(1) : tag;
|
||||
|
||||
if (packageJson.version !== manifest.version) {
|
||||
fail(`package.json version ${packageJson.version} does not match manifest.json version ${manifest.version}`);
|
||||
}
|
||||
|
||||
if (!versions[manifest.version]) {
|
||||
fail(`versions.json does not contain ${manifest.version}`);
|
||||
}
|
||||
|
||||
if (normalizedTag && normalizedTag !== manifest.version) {
|
||||
fail(`Git tag ${tag} does not match manifest.json version ${manifest.version}`);
|
||||
}
|
||||
|
||||
for (const path of ["manifest.json", "dist/main.js", "dist/main.css"]) {
|
||||
if (!existsSync(path)) {
|
||||
fail(`Missing release file: ${path}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Release files validated for ${manifest.version}`);
|
||||
|
||||
function readJson(path) {
|
||||
return JSON.parse(readFileSync(path, "utf8"));
|
||||
}
|
||||
|
||||
function fail(message) {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue