ci(pulumigo): split build, test, and release jobs for clarity and control

This commit is contained in:
Haitao Pan 2025-05-19 11:55:40 +08:00
parent c78a1ba6a1
commit a07fcfd074

View File

@ -18,16 +18,17 @@ on:
- 'PulumiGo/internal/**'
- '.github/workflows/build-pulumigo.yml'
schedule:
- cron: '0 2 * * *' # 每天 UTC 凌晨 2 点
- cron: '0 2 * * *'
workflow_dispatch:
jobs:
build-and-test:
build:
name: Build binaries
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
arch: [amd64, arm64]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
@ -39,30 +40,50 @@ jobs:
go-version: '1.21'
- name: Build PulumiGo binary
working-directory: PulumiGo
run: |
mkdir -p dist
GOARCH=${{ matrix.arch }} GOOS=linux go build -o dist/PulumiGo-${{ matrix.os }}-${{ matrix.arch }} main.go
GOOS=linux GOARCH=${{ matrix.arch }} go build -o dist/PulumiGo-${{ matrix.os }}-${{ matrix.arch }} main.go
- name: Compress binary
working-directory: PulumiGo
run: |
cd dist
tar -czvf PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz PulumiGo-${{ matrix.os }}-${{ matrix.arch }}
- name: Upload Artifact
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pulumigo-${{ matrix.os }}-${{ matrix.arch }}
path: dist/PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
path: PulumiGo/dist/PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
- name: Run CLI --help test
test:
name: Test CLI execution
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-20.04]
arch: [amd64]
steps:
- name: Download binary
uses: actions/download-artifact@v4
with:
name: pulumigo-${{ matrix.os }}-${{ matrix.arch }}
path: test-dir
- name: Extract and test CLI
run: |
cd dist
tar -xzvf PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
cd test-dir
tar -xzf PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
chmod +x PulumiGo-${{ matrix.os }}-${{ matrix.arch }}
./PulumiGo-${{ matrix.os }}-${{ matrix.arch }} --help
publish-release:
needs: build-and-test
name: Publish Daily Release
if: github.event_name == 'push' || github.event_name == 'schedule'
needs: test
runs-on: ubuntu-latest
env:
tag_name: daily-${{ github.run_id }}
@ -82,7 +103,7 @@ jobs:
tag_name: ${{ env.tag_name }}
name: ${{ env.release_name }}
prerelease: true
files: release-artifacts/**/*.tar.gz
files: |
release-artifacts/**/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}