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",
"build": "tsc && vite build",
"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": {
"@headlessui/react": "^2.1.10",
@@ -61,7 +64,9 @@
"autoprefixer": "^10.4.20",
"immer": "^10.1.1",
"postcss": "^8.4.47",
"release-it": "^18.1.2",
"tailwindcss": "^3.4.14",
"tsx": "^4.19.3",
"typescript": "^5.2.2",
"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,
"visible": false,
"windowEffects": {
"effects": [
"sidebar"
],
"effects": ["sidebar"],
"state": "active"
}
}
@@ -62,9 +60,7 @@
"assetProtocol": {
"enable": true,
"scope": {
"allow": [
"**/*"
],
"allow": ["**/*"],
"requireLiteralLeadingDot": false
}
}
@@ -72,7 +68,8 @@
},
"bundle": {
"active": true,
"targets": "all",
"createUpdaterArtifacts": true,
"targets": ["nsis", "dmg", "app", "appimage", "deb", "rpm"],
"category": "Utility",
"shortDescription": "Coco AI",
"icon": [
@@ -107,22 +104,15 @@
}
}
},
"resources": [
"assets",
"icons"
]
"resources": ["assets", "icons"]
},
"plugins": {
"features": {
"protocol": [
"all"
]
"protocol": ["all"]
},
"window": {},
"updater": {
"dialog": true,
"active": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEM5RjNFQUM3NDdGMjgzNUIKUldSYmcvSkh4K3J6eWFrYlRGTjFPZTJXQWIyMGJtWjdLVUplZm9kcHcvdWQ0aTZjMUYvOUJ5K08K",
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDlDRjNDRUU0NTdBMzdCRTMKUldUamU2Tlg1TTd6bkUwZWM0d2Zjdk0wdXJmendWVlpMMmhKN25EcmprYmIydnJ3dmFUME9QYXkK",
"endpoints": [
"https://api.coco.rs/update/{{target}}/{{arch}}/{{current_version}}"
]
@@ -135,15 +125,11 @@
"mobile": [
{
"host": "app.infini.cloud",
"pathPrefix": [
"/open"
]
"pathPrefix": ["/open"]
}
],
"desktop": {
"schemes": [
"coco"
]
"schemes": ["coco"]
}
},
"os": {}