build: 使用环境变量替代矩阵策略中的目标架构

- 将 matrix.target_arch 替换为 fromJson(env.TARGET_ARCH)
- 更新构建和上传/下载工件的步骤以使用新的环境变量
- 删除冗余的矩阵配置,简化工作流结构
This commit is contained in:
tidex 2025-02-25 22:41:34 +08:00
parent b94ac63708
commit 787cf4b8ee
1 changed files with 8 additions and 17 deletions

View File

@ -12,9 +12,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
target_arch: target_arch: ${{ fromJson(env.TARGET_ARCH) }}
- "mipsle-softfloat"
- "mipsle-hardfloat"
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -34,17 +32,15 @@ jobs:
needs: setup needs: setup
strategy: strategy:
matrix: matrix:
target_arch: target_arch: ${{ fromJson(env.TARGET_ARCH) }}
- "mipsle-softfloat"
- "mipsle-hardfloat"
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Build - name: Build
env: env:
GOARCH: ${{ contains(matrix.target_arch, 'mipsle') && 'mipsle' || '' }} GOARCH: ${{ contains(fromJson(env.TARGET_ARCH), 'mipsle') && 'mipsle' || '' }}
GOMIPS: ${{ contains(matrix.target_arch, 'softfloat') && 'softfloat' || 'hardfloat' }} GOMIPS: ${{ contains(fromJson(env.TARGET_ARCH), 'softfloat') && 'softfloat' || 'hardfloat' }}
CGO_ENABLED: 0 CGO_ENABLED: 0
run: | run: |
echo "Building for GOARCH=${GOARCH} GOMIPS=${GOMIPS}" echo "Building for GOARCH=${GOARCH} GOMIPS=${GOMIPS}"
@ -53,17 +49,12 @@ jobs:
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: cloudflared-${{ matrix.target_arch }} name: cloudflared-${{ fromJson(env.TARGET_ARCH) }}
path: cloudflared-${{ matrix.target_arch }} path: cloudflared-${{ fromJson(env.TARGET_ARCH) }}
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
strategy:
matrix:
target_arch:
- "mipsle-softfloat"
- "mipsle-hardfloat"
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -71,13 +62,13 @@ jobs:
- name: Download Artifact - name: Download Artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: cloudflared-${{ matrix.target_arch }} name: cloudflared-${{ fromJson(env.TARGET_ARCH) }}
path: . path: .
- name: Generate SHA Sums - name: Generate SHA Sums
run: | run: |
echo "Generating SHA sums for release assets..." echo "Generating SHA sums for release assets..."
sha256sum cloudflared-${{ matrix.target_arch }} > SHA256_SUMS sha256sum cloudflared-${{ fromJson(env.TARGET_ARCH) }} > SHA256_SUMS
cat SHA256_SUMS cat SHA256_SUMS
- name: Release - name: Release