Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

ci: combine two workflow

PairZhuaa7fb14f34e8
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
deleted file mode 100644
index eb50d708..00000000
--- a/.github/workflows/desktop-release.yml
+++ /dev/null
@@ -1,166 +0,0 @@
-name: desktop-release
-
-on:
- workflow_run:
- workflows: ["release"]
- types:
- - completed
- workflow_dispatch:
- inputs:
- tag:
- description: 'Tag to build (e.g. v1.0.0)'
- required: true
- type: string
-
-permissions:
- contents: write
-
-jobs:
- prepare:
- runs-on: ubuntu-latest
- if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
- outputs:
- tag: ${{ steps.tag.outputs.tag }}
- commit_sha: ${{ steps.commit_sha.outputs.commit_sha }}
- upload_url: ${{ steps.upload_url.outputs.upload_url }}
- steps:
- - name: Get Commit SHA
- id: commit_sha
- uses: actions/github-script@v7
- with:
- script: |
- let sha;
- if (context.eventName === 'workflow_dispatch') {
- // For manual triggers, get the commit SHA for the specified tag
- try {
- const { data: ref } = await github.rest.git.getRef({
- owner: context.repo.owner,
- repo: context.repo.repo,
- ref: `tags/${context.payload.inputs.tag}`
- });
-
- if (ref.object.type === 'tag') {
- // If the tag is an annotated tag, we need to fetch the commit ID from the tag's object
- const { data: tagObject } = await github.rest.git.getTag({
- owner: context.repo.owner,
- repo: context.repo.repo,
- tag_sha: ref.object.sha
- });
- sha = tagObject.object.sha; // The sha of the commit the annotated tag points to
- } else {
- sha = ref.object.sha; // Direct commit SHA for lightweight tag
- }
-
- } catch (error) {
- throw new Error(`Failed to get commit SHA for tag ${context.payload.inputs.tag}: ${error.message}`);
- }
- } else {
- // For workflow_run triggers, use the commit SHA from the workflow_run event
- sha = context.payload.workflow_run.head_sha;
- }
-
- console.log(`Commit SHA: ${sha}`);
- core.setOutput('commit_sha', sha);
-
- - name: Get Tag
- id: tag
- uses: actions/github-script@v7
- with:
- script: |
- let tag;
- if (context.eventName === 'workflow_dispatch') {
- tag = context.payload.inputs.tag;
- } else {
- // Get the tag from the workflow_run event
- tag = context.payload.workflow_run.head_branch;
- }
- console.log(`Tag: ${tag}`);
- core.setOutput('tag', tag);
-
- - name: Get Upload URL
- id: upload_url
- uses: actions/github-script@v7
- with:
- script: |
- const { data: release } = await github.rest.repos.getReleaseByTag({
- owner: context.repo.owner,
- repo: context.repo.repo,
- tag: '${{ steps.tag.outputs.tag }}',
- });
- console.log(`Upload URL: ${release.upload_url}`);
- core.setOutput('upload_url', release.upload_url);
-
- build:
- needs: prepare
- if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
- strategy:
- fail-fast: false
- matrix:
- include:
- - os: darwin
- arch: amd64
- suffix: _amd64
- display_os: macOS
- - os: darwin
- arch: arm64
- suffix: _arm64
- display_os: macOS
- - os: windows
- arch: amd64
- suffix: .exe
- display_os: Windows
- - os: windows
- arch: 386
- suffix: _i386.exe
- display_os: Windows
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- ref: ${{ needs.prepare.outputs.commit_sha }}
-
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v3
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Set up Go
- uses: actions/setup-go@v5
- with:
- go-version-file: 'go.mod'
-
- - name: Install XGO
- run: |
- go install src.techknowlogick.com/xgo@latest
-
- - name: Build Binary
- run: |
- xgo --targets=${{ matrix.os }}/${{ matrix.arch }} \
- --out krillinai_desktop \
- ./cmd/desktop
-
- - name: Rename Binary
- run: |
- mv krillinai_desktop* KrillinAI_Desktop${{ matrix.suffix }}
-
- - name: Get Version
- id: version
- uses: actions/github-script@v7
- with:
- script: |
- const rawTag = '${{ needs.prepare.outputs.tag }}';
- const version = rawTag.replace(/^v/, ''); // Remove the leading 'v' if present
- console.log(`Version: ${version}`);
- core.setOutput('version', version);
-
- - name: Upload Binary
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ needs.prepare.outputs.upload_url }}
- asset_path: KrillinAI_Desktop${{ matrix.suffix }}
- asset_name: KrillinAI_Desktop_${{ steps.version.outputs.version }}_${{ matrix.display_os }}${{ matrix.suffix }}
- asset_content_type: application/octet-stream
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 57d8944f..7c575a81 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -3,32 +3,119 @@ name: release
on:
push:
tags:
- - 'v*'
- - 'v*-*'
+ - "v*"
+ - "v*-*"
permissions:
contents: write
jobs:
- goreleaser:
+ build-desktop:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- with:
- fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version-file: 'go.mod'
+ go-version-file: "go.mod"
+
+ - name: Install XGO
+ run: |
+ go install src.techknowlogick.com/xgo@latest
+
+ - name: Pull Docker Image
+ run: |
+ docker pull ghcr.io/techknowlogick/xgo:latest
+
+ - name: Get Version
+ id: version
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const rawTag = '${{ github.ref_name }}';
+ const version = rawTag.replace(/^v/, ''); // Remove the leading 'v' if present
+ console.log(`Version: ${version}`);
+ core.setOutput('version', version);
+
+ - name: Build Binary
+ run: |
+ targets=(
+ # macOS (amd64)
+ "darwin amd64 _amd64 macOS"
+ # macOS (arm64)
+ "darwin arm64 _arm64 macOS"
+ # Windows (amd64)
+ "windows amd64 .exe Windows"
+ # Windows (386)
+ "windows 386 _i386.exe Windows"
+ )
+ mkdir -p build
+ # 遍历所有平台
+ for entry in "${targets[@]}"; do
+ (
+ # 拆分字符串
+ IFS=' ' read -r -a parts <<< "$entry"
+ os="${parts[0]}"
+ arch="${parts[1]}"
+ suffix="${parts[2]}"
+ display_os="${parts[3]}"
+ log_prefix="[${os}-${arch}]"
+ # 构建目标目录
+ target_dir="dist/${os}_${arch}"
+ mkdir -p "$target_dir"
+ # 使用 xgo 构建
+ echo "${log_prefix} 🚀 Building for $os/$arch..."
+ xgo \
+ --targets="$os/$arch" \
+ --out "krillinai_desktop" \
+ --dest "$target_dir" \
+ ./cmd/desktop 2>&1 | sed "s/^/${log_prefix} /"
+ # 生成最终二进制文件名日志输
+ binary_name="KrillinAI_Desktop_${{ steps.version.outputs.version }}_${display_os}${suffix}"
+ # 移动并重命名文件
+ mv "$target_dir"/krillinai_desktop* "build/$binary_name"
+ echo "${log_prefix} ✅ Built: build/$binary_name"
+ ) &
+ done
+
+ wait
+ echo "✨ All concurrent tasks completed!"
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@v4
+ with:
+ path: build/*
+ retention-days: 1
+
+ goreleaser:
+ needs: build-desktop
+ if: always()
+ runs-on: ubuntu-latest
+ steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
+
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 20
+
+ - name: Download artifacts
+ uses: actions/download-artifact@v4
+ with:
+ path: build
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: "go.mod"
+
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index e66268df..e0a8a953 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -47,7 +47,7 @@ docker_manifests:
- "{{ tolower .Env.DOCKER_USERNAME }}/{{ tolower .ProjectName }}:latest-arm64"
archives:
- - format: binary
+ - formats: ["binary"]
name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
@@ -60,6 +60,10 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
{{- end }}
+release:
+ extra_files:
+ - glob: "build/*"
+
changelog:
sort: asc
filters:
@@ -67,4 +71,4 @@ changelog:
- "^docs:"
- "^test:"
- "^chore:"
- - "^ci:"
\ No newline at end of file
+ - "^ci:"