chore: support for github action releases (#169)

* chore: support for github action releases (#165)

* chore: support for generating update files (#168)

* chore: support for github action releases

* chore: support for generating update files

* chore: include TAURI_SIGNING_PRIVATE_KEY_PASSWORD variable in the release

* chore: replacing the pubkey when updating
This commit is contained in:
ayangweb
2025-02-21 16:52:52 +08:00
committed by GitHub
parent 181575d3ad
commit ca9adb515b
6 changed files with 2232 additions and 37 deletions

106
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,106 @@
name: "publish"
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Generate changelog
id: create_release
run: npx changelogithub --draft --name ${{ steps.vars.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
build-app:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-latest"
target: "aarch64-apple-darwin"
- platform: "macos-latest"
target: "x86_64-apple-darwin"
- platform: "windows-latest"
target: "x86_64-pc-windows-msvc"
- platform: "windows-latest"
target: "i686-pc-windows-msvc"
- platform: "windows-latest"
target: "aarch64-pc-windows-msvc"
- platform: "ubuntu-22.04"
target: "x86_64-unknown-linux-gnu"
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Install rust target
run: rustup target add ${{ matrix.target }}
- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri/target
- name: Sync node version and setup cache
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install app dependencies and build web
run: pnpm install --frozen-lockfile
- name: Build the app
uses: tauri-apps/tauri-action@v0
env:
CI: false
PLATFORM: ${{ matrix.platform }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
with:
tagName: ${{ github.ref_name }}
releaseName: Coco ${{ needs.create-release.outputs.APP_VERSION }}
releaseBody: ""
releaseDraft: true
prerelease: false
args: --target ${{ matrix.target }}

14
.release-it.ts Normal file
View File

@@ -0,0 +1,14 @@
import type { Config } from "release-it";
export default {
git: {
commitMessage: "v${version}",
tagName: "v${version}",
},
npm: {
publish: false,
},
hooks: {
"after:bump": "tsx scripts/release.ts",
},
} satisfies Config;

View File

@@ -7,7 +7,10 @@
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview", "preview": "vite preview",
"tauri": "tauri" "tauri": "tauri",
"release": "release-it",
"release-rc": "release-it --preRelease=rc --preReleaseBase=1",
"release-beta": "release-it --preRelease=beta --preReleaseBase=1"
}, },
"dependencies": { "dependencies": {
"@headlessui/react": "^2.1.10", "@headlessui/react": "^2.1.10",
@@ -61,7 +64,9 @@
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"immer": "^10.1.1", "immer": "^10.1.1",
"postcss": "^8.4.47", "postcss": "^8.4.47",
"release-it": "^18.1.2",
"tailwindcss": "^3.4.14", "tailwindcss": "^3.4.14",
"tsx": "^4.19.3",
"typescript": "^5.2.2", "typescript": "^5.2.2",
"vite": "^5.3.1" "vite": "^5.3.1"
} }

2087
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

23
scripts/release.ts Normal file
View File

@@ -0,0 +1,23 @@
import { readFileSync, writeFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { name, version } from "../package.json";
const __dirname = dirname(fileURLToPath(import.meta.url));
(() => {
const tomlPath = resolve(__dirname, "..", "src-tauri", "Cargo.toml");
const lockPath = resolve(__dirname, "..", "src-tauri", "Cargo.lock");
for (const path of [tomlPath, lockPath]) {
let content = readFileSync(path, "utf-8");
const regexp = new RegExp(
`(name\\s*=\\s*"${name}"\\s*version\\s*=\\s*)"(\\d+\\.\\d+\\.\\d+(-\\w+\\.\\d+)?)"`
);
content = content.replace(regexp, `$1"${version}"`);
writeFileSync(path, content);
}
})();

View File

@@ -49,9 +49,7 @@
"hiddenTitle": true, "hiddenTitle": true,
"visible": false, "visible": false,
"windowEffects": { "windowEffects": {
"effects": [ "effects": ["sidebar"],
"sidebar"
],
"state": "active" "state": "active"
} }
} }
@@ -62,9 +60,7 @@
"assetProtocol": { "assetProtocol": {
"enable": true, "enable": true,
"scope": { "scope": {
"allow": [ "allow": ["**/*"],
"**/*"
],
"requireLiteralLeadingDot": false "requireLiteralLeadingDot": false
} }
} }
@@ -72,7 +68,8 @@
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"targets": "all", "createUpdaterArtifacts": true,
"targets": ["nsis", "dmg", "app", "appimage", "deb", "rpm"],
"category": "Utility", "category": "Utility",
"shortDescription": "Coco AI", "shortDescription": "Coco AI",
"icon": [ "icon": [
@@ -107,22 +104,15 @@
} }
} }
}, },
"resources": [ "resources": ["assets", "icons"]
"assets",
"icons"
]
}, },
"plugins": { "plugins": {
"features": { "features": {
"protocol": [ "protocol": ["all"]
"all"
]
}, },
"window": {}, "window": {},
"updater": { "updater": {
"dialog": true, "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDlDRjNDRUU0NTdBMzdCRTMKUldUamU2Tlg1TTd6bkUwZWM0d2Zjdk0wdXJmendWVlpMMmhKN25EcmprYmIydnJ3dmFUME9QYXkK",
"active": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEM5RjNFQUM3NDdGMjgzNUIKUldSYmcvSkh4K3J6eWFrYlRGTjFPZTJXQWIyMGJtWjdLVUplZm9kcHcvdWQ0aTZjMUYvOUJ5K08K",
"endpoints": [ "endpoints": [
"https://api.coco.rs/update/{{target}}/{{arch}}/{{current_version}}" "https://api.coco.rs/update/{{target}}/{{arch}}/{{current_version}}"
] ]
@@ -135,15 +125,11 @@
"mobile": [ "mobile": [
{ {
"host": "app.infini.cloud", "host": "app.infini.cloud",
"pathPrefix": [ "pathPrefix": ["/open"]
"/open"
]
} }
], ],
"desktop": { "desktop": {
"schemes": [ "schemes": ["coco"]
"coco"
]
} }
}, },
"os": {} "os": {}