mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
- Changed the fetch depth to 0 in the release workflow to ensure all history is available for tagging. This adjustment improves the accuracy of the release process.
153 lines
4.6 KiB
YAML
153 lines
4.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Release tag (e.g. v1.0.0)'
|
|
required: true
|
|
default: 'v1.0.0'
|
|
push:
|
|
tags:
|
|
- v*.*.*
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Check out Git repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get release tag
|
|
id: get-tag
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: macos-latest dependencies fix
|
|
if: matrix.os == 'macos-latest'
|
|
run: |
|
|
brew install python-setuptools
|
|
|
|
- name: Install corepack
|
|
run: corepack enable && corepack prepare yarn@4.6.0 --activate
|
|
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache-dir-path
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache yarn dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
node_modules
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-
|
|
|
|
- name: Install Dependencies
|
|
run: yarn install
|
|
|
|
- name: Build Linux
|
|
if: matrix.os == 'ubuntu-latest'
|
|
run: |
|
|
yarn build:npm linux
|
|
yarn build:linux
|
|
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }}
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
|
|
- name: Build Mac
|
|
if: matrix.os == 'macos-latest'
|
|
run: |
|
|
sudo -H pip install setuptools
|
|
yarn build:npm mac
|
|
yarn build:mac
|
|
env:
|
|
CSC_LINK: ${{ secrets.CSC_LINK }}
|
|
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
|
|
APPLE_ID: ${{ vars.APPLE_ID }}
|
|
APPLE_APP_SPECIFIC_PASSWORD: ${{ vars.APPLE_APP_SPECIFIC_PASSWORD }}
|
|
APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
|
|
RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }}
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
|
|
- name: Build Windows
|
|
if: matrix.os == 'windows-latest'
|
|
run: |
|
|
yarn build:npm windows
|
|
yarn build:win
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RENDERER_VITE_AIHUBMIX_SECRET: ${{ vars.RENDERER_VITE_AIHUBMIX_SECRET }}
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
|
|
- name: Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
draft: true
|
|
allowUpdates: true
|
|
makeLatest: false
|
|
tag: ${{ steps.get-tag.outputs.tag }}
|
|
artifacts: 'dist/*.exe,dist/*.zip,dist/*.dmg,dist/*.AppImage,dist/*.snap,dist/*.deb,dist/*.rpm,dist/*.tar.gz,dist/latest*.yml,dist/rc*.yml,dist/*.blockmap'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
dispatch-docs-update:
|
|
needs: release
|
|
if: success() && github.repository == 'CherryHQ/cherry-studio' # 确保所有构建成功且在主仓库中运行
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Get release tag
|
|
id: get-tag
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Check if tag is pre-release
|
|
id: check-tag
|
|
shell: bash
|
|
run: |
|
|
TAG="${{ steps.get-tag.outputs.tag }}"
|
|
if [[ "$TAG" == *"rc"* || "$TAG" == *"pre-release"* ]]; then
|
|
echo "is_pre_release=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "is_pre_release=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Dispatch update-download-version workflow to cherry-studio-docs
|
|
if: steps.check-tag.outputs.is_pre_release == 'false'
|
|
uses: peter-evans/repository-dispatch@v3
|
|
with:
|
|
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
|
|
repository: CherryHQ/cherry-studio-docs
|
|
event-type: update-download-version
|
|
client-payload: '{"version": "${{ steps.get-tag.outputs.tag }}"}'
|