fix(release): skip opposite platform push builds

This commit is contained in:
DIYgod
2026-05-29 15:46:38 +08:00
parent a1988abc0c
commit 295f7e4291
4 changed files with 52 additions and 4 deletions
@@ -0,0 +1,25 @@
import { readFileSync } from "node:fs"
import { describe, expect, it } from "vitest"
const workflow = (name: string) => readFileSync(`.github/workflows/${name}`, "utf8")
describe("release build workflow guards", () => {
it("skips direct mobile push builds for desktop release commits on main", () => {
const androidWorkflow = workflow("build-android.yml")
const iosWorkflow = workflow("build-ios.yml")
expect(androidWorkflow).toContain("github.ref == 'refs/heads/main'")
expect(androidWorkflow).toContain("release(desktop):")
expect(iosWorkflow).toContain("github.ref == 'refs/heads/main'")
expect(iosWorkflow).toContain("release(desktop):")
})
it("skips direct desktop push builds for mobile release commits on mobile-main", () => {
const desktopWorkflow = workflow("build-desktop.yml")
expect(desktopWorkflow).toContain("github.ref == 'refs/heads/mobile-main'")
expect(desktopWorkflow).toContain("release(mobile):")
})
})
+9 -2
View File
@@ -29,9 +29,16 @@ concurrency:
jobs:
build:
name: Build Android apk for device
if: github.secret_source != 'None' && (github.event_name != 'push' || github.ref != 'refs/heads/mobile-main' || !contains(github.event.head_commit.message || '', 'release(mobile):'))
if: >-
github.secret_source != 'None' &&
(
github.event_name != 'push' ||
!(
(github.ref == 'refs/heads/mobile-main' && contains(github.event.head_commit.message || '', 'release(mobile):')) ||
(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message || '', 'release(desktop):'))
)
)
runs-on: ubuntu-latest
steps:
- name: 🧹 Claim disk space
run: |
+9 -1
View File
@@ -39,7 +39,15 @@ env:
jobs:
release:
if: github.secret_source != 'None' && (github.event_name != 'push' || github.ref != 'refs/heads/main' || !contains(github.event.head_commit.message || '', 'release(desktop):'))
if: >-
github.secret_source != 'None' &&
(
github.event_name != 'push' ||
!(
(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message || '', 'release(desktop):')) ||
(github.ref == 'refs/heads/mobile-main' && contains(github.event.head_commit.message || '', 'release(mobile):'))
)
)
runs-on: ${{ matrix.os }}
env:
PROD: ${{ github.event.inputs.tag_version == 'true' || github.ref_type == 'tag' || github.event.inputs.store == 'true' }}
+9 -1
View File
@@ -23,7 +23,15 @@ concurrency:
jobs:
check-runner:
if: github.secret_source != 'None' && (github.event_name != 'push' || github.ref != 'refs/heads/mobile-main' || !contains(github.event.head_commit.message || '', 'release(mobile):'))
if: >-
github.secret_source != 'None' &&
(
github.event_name != 'push' ||
!(
(github.ref == 'refs/heads/mobile-main' && contains(github.event.head_commit.message || '', 'release(mobile):')) ||
(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message || '', 'release(desktop):'))
)
)
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.set-runner.outputs.runner-label }}