mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
chore: action
This commit is contained in:
parent
2d0cac6766
commit
a67bd0468a
211
.github/workflows/release.yml
vendored
211
.github/workflows/release.yml
vendored
@ -6,170 +6,181 @@ on:
|
|||||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
build-chatgpt:
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# outputs:
|
|
||||||
# RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Query version number
|
|
||||||
id: get_version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "using version tag ${GITHUB_REF:10}"
|
|
||||||
echo "version=${GITHUB_REF:10}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: '${{ env.version }}'
|
|
||||||
release_name: 'ChatGPT ${{ env.version }}'
|
|
||||||
body: 'See the assets to download this version and install.'
|
|
||||||
|
|
||||||
build-tauri:
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 40
|
|
||||||
needs: create-release
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- build: linux
|
- build: linux
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
rust: stable
|
arch: x86_64
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
- build: linux
|
|
||||||
os: ubuntu-latest
|
|
||||||
rust: stable
|
|
||||||
target: aarch64-unknown-linux-gnu
|
|
||||||
- build: macos
|
- build: macos
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
rust: stable
|
arch: x86_64
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
- buid: macos
|
- buid: macos
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
rust: stable
|
arch: aarch64
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
- build: windows
|
- build: windows
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
rust: stable
|
arch: x86_64
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v2
|
||||||
|
name: Install pnpm
|
||||||
|
id: pnpm-install
|
||||||
|
with:
|
||||||
|
version: 7
|
||||||
|
run_install: false
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
cache-dependency-path: chatgpt/pnpm-lock.yaml
|
- run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: 'Setup Rust'
|
- name: 'Setup Rust'
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
targets: ${{ matrix.config.rust_target }}
|
targets: ${{ matrix.target }}
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
key: ${{ matrix.config.rust_target }}
|
key: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: install dependencies (ubuntu only)
|
- name: Install dependencies (ubuntu only)
|
||||||
if: matrix.platform == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Build FE
|
||||||
run: cd chatgpt && pnpm install --force
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: pnpm build:fe
|
run: pnpm build:fe
|
||||||
|
|
||||||
# - name: Rewrite tauri.conf.json
|
|
||||||
# run: pnpm fix:conf
|
|
||||||
|
|
||||||
- name: Install rust target
|
- name: Install rust target
|
||||||
run: rustup target add ${{ matrix.target }}
|
run: rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
- name: fix tray icon
|
- name: fix tray icon
|
||||||
if: matrix.platform != 'macos-latest'
|
if: matrix.os != 'macos-latest'
|
||||||
run: |
|
run: |
|
||||||
pnpm fix:tray
|
pnpm fix:tray
|
||||||
|
|
||||||
- uses: tauri-apps/tauri-action@v0.3
|
- run: pnpm build --target ${{ matrix.target }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# 📝: https://tauri.app/v1/guides/distribution/updater#signing-updates
|
|
||||||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
with:
|
|
||||||
args: --target ${{ matrix.target }}
|
|
||||||
# releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: matrix.target == 'aarch64-apple-darwin'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
with:
|
with:
|
||||||
name: chatgpt-macos-aarch64
|
name: artifacts-${{ matrix.arch }}
|
||||||
path: ./target/aarch64-apple-darwin/release/bundle/macos/ChatGPT.app.tar.*
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: matrix.target == 'x86_64-apple-darwin'
|
|
||||||
with:
|
|
||||||
name: chatgpt-macos
|
|
||||||
path: ./target/x86_64-apple-darwin/release/bundle/macos/ChatGPT.app.tar.*
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: matrix.platform == 'windows-latest'
|
|
||||||
with:
|
|
||||||
name: chatgpt-windows
|
|
||||||
path: ./target/x86_64-pc-windows-msvc/release/bundle/msi/ChatGPT_**.msi.zip.*
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: matrix.target == 'x86_64-unknown-linux-gnu'
|
|
||||||
with:
|
|
||||||
name: chatgpt-linux
|
|
||||||
path: |
|
path: |
|
||||||
./target/x86_64-unknown-linux-gnu/release/bundle/appimage/chat-gpt_**.deb
|
./target/${{ matrix.target }}/release/bundle/appimage/**.AppImage.*
|
||||||
./target/x86_64-unknown-linux-gnu/release/bundle/appimage/chat-gpt_**.AppImage.tar.*
|
./target/${{ matrix.target }}/release/bundle/deb/**.deb
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: matrix.target == 'aarch64-unknown-linux-gnu'
|
if: matrix.os == 'macos-latest'
|
||||||
with:
|
with:
|
||||||
name: chatgpt-linux
|
name: artifacts-${{ matrix.arch }}
|
||||||
path: |
|
path: |
|
||||||
./target/aarch64-unknown-linux-gnu/release/bundle/appimage/chat-gpt_**.deb
|
./target/${{ matrix.target }}/release/bundle/dmg/**.dmg
|
||||||
./target/aarch64-unknown-linux-gnu/release/bundle/appimage/chat-gpt_**.AppImage.tar.*
|
./target/${{ matrix.target }}/release/bundle/macos/**.app.*
|
||||||
|
|
||||||
# updater:
|
- uses: actions/upload-artifact@v3
|
||||||
# runs-on: ubuntu-latest
|
if: matrix.os == 'windows-latest'
|
||||||
# needs: [create-release, build-tauri]
|
with:
|
||||||
|
name: artifacts-${{ matrix.arch }}
|
||||||
|
path: |
|
||||||
|
./target/${{ matrix.target }}/release/bundle/msi/**
|
||||||
|
|
||||||
# steps:
|
release-chatgpt:
|
||||||
# - uses: actions/checkout@v3
|
needs: build-chatgpt
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
# - name: Install Node.js
|
- name: Query version number
|
||||||
# uses: actions/setup-node@v3
|
run: echo "version=${GITHUB_REF:11}" >> $GITHUB_ENV
|
||||||
# with:
|
|
||||||
# node-version: 18
|
|
||||||
# cache: pnpm
|
|
||||||
# cache-dependency-path: chatgpt/pnpm-lock.yaml
|
|
||||||
|
|
||||||
# - name: Install dependencies
|
- name: Download x86_64 artifacts
|
||||||
# run: cd chatgpt && pnpm install --force
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts-x86_64
|
||||||
|
path: artifacts/x86_64
|
||||||
|
|
||||||
# - run: pnpm updater --token=${{ secrets.GITHUB_TOKEN }}
|
- name: Download aarch64 artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts-aarch64
|
||||||
|
path: artifacts/aarch64
|
||||||
|
|
||||||
# - name: Deploy install.json
|
- name: Rename artifacts
|
||||||
# uses: peaceiris/actions-gh-pages@v3
|
run: |
|
||||||
# with:
|
mv "artifacts/aarch64/dmg/ChatGPT_${{ env.version }}_aarch64.dmg" "artifacts/ChatGPT_${{ env.version }}_macos_aarch64.dmg"
|
||||||
# github_token: ${{ secrets.GITHUB_TOKEN }}
|
mv "artifacts/aarch64/macos/ChatGPT.app.tar.gz" "artifacts/ChatGPT_${{ env.version }}_macos_aarch64.app.tar.gz"
|
||||||
# # 📝: Edit the deployment directory
|
mv "artifacts/aarch64/macos/ChatGPT.app.tar.gz.sig" "artifacts/ChatGPT_${{ env.version }}_macos_aarch64.app.tar.gz.sig"
|
||||||
# publish_dir: ./updater
|
|
||||||
# # force_orphan: true
|
mv "artifacts/x86_64/dmg/ChatGPT_${{ env.version }}_x64.dmg" "artifacts/ChatGPT_${{ env.version }}_macos_x86_64.dmg"
|
||||||
|
mv "artifacts/x86_64/macos/ChatGPT.app.tar.gz" "artifacts/ChatGPT_${{ env.version }}_macos_x86_64.app.tar.gz"
|
||||||
|
mv "artifacts/x86_64/macos/ChatGPT.app.tar.gz.sig" "artifacts/ChatGPT_${{ env.version }}_macos_x86_64.app.tar.gz.sig"
|
||||||
|
|
||||||
|
mv "artifacts/x86_64/deb/chat-gpt_${{ env.version }}_amd64.deb" "artifacts/x86_64/deb/ChatGPT_${{ env.version }}_linux_x86_64.deb"
|
||||||
|
mv "artifacts/x86_64/appimage/chat-gpt_${{ env.version }}_amd64.AppImage.tar.gz" "artifacts/ChatGPT_${{ env.version }}_linux_x86_64.AppImage.tar.gz"
|
||||||
|
mv "artifacts/x86_64/appimage/chat-gpt_${{ env.version }}_amd64.AppImage.tar.gz.sig" "artifacts/ChatGPT_${{ env.version }}_linux_x86_64.AppImage.tar.gz.sig"
|
||||||
|
|
||||||
|
mv "artifacts/x86_64/ChatGPT_${{ env.version }}_x64_en-US.msi" "artifacts/ChatGPT_${{ env.version }}_windows_x86_64.msi"
|
||||||
|
mv "artifacts/x86_64/ChatGPT_${{ env.version }}_x64_en-US.msi.zip" "artifacts/ChatGPT_${{ env.version }}_windows_x86_64.msi.zip"
|
||||||
|
mv "artifacts/x86_64/ChatGPT_${{ env.version }}_x64_en-US.msi.zip.sig" "artifacts/ChatGPT_${{ env.version }}_windows_x86_64.msi.zip.sig"
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: v${{ env.version }}
|
||||||
|
name: ChatGPT v${{ env.version }}
|
||||||
|
body: See the assets to download this version and install.
|
||||||
|
prerelease: false
|
||||||
|
generate_release_notes: false
|
||||||
|
files: ./artifacts/**/*
|
||||||
|
|
||||||
|
updater:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release-chatgpt
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v2
|
||||||
|
name: Install pnpm
|
||||||
|
id: pnpm-install
|
||||||
|
with:
|
||||||
|
version: 7
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
cache: pnpm
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Updater JSON
|
||||||
|
run: pnpm updater --token=${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Deploy install.json
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./updater
|
||||||
|
# force_orphan: true
|
||||||
|
|
||||||
# publish-winget:
|
# publish-winget:
|
||||||
# # Action can only be run on windows
|
# # Action can only be run on windows
|
||||||
|
33
scripts/download.js
vendored
33
scripts/download.js
vendored
@ -1,33 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const argv = process.argv.slice(2);
|
|
||||||
|
|
||||||
async function rewrite(filename) {
|
|
||||||
const content = fs.readFileSync(filename, 'utf8').split('\n');
|
|
||||||
const startRe = /<!-- download start -->/;
|
|
||||||
const endRe = /<!-- download end -->/;
|
|
||||||
|
|
||||||
let flag = false;
|
|
||||||
for (let i = 0; i < content.length; i++) {
|
|
||||||
if (startRe.test(content[i])) {
|
|
||||||
flag = true;
|
|
||||||
}
|
|
||||||
if (flag) {
|
|
||||||
if (!/winget install --id=lencx.ChatGPT -e --version/.test(content[i])) {
|
|
||||||
content[i] = content[i].replace(/(\d+).(\d+).(\d+)/g, argv[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (endRe.test(content[i])) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(filename, content.join('\n'), 'utf8');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function init() {
|
|
||||||
rewrite('README.md');
|
|
||||||
rewrite('README-ZH_CN.md');
|
|
||||||
}
|
|
||||||
|
|
||||||
init().catch(console.error);
|
|
Loading…
Reference in New Issue
Block a user