ci(pulumigo): add path-based trigger filter to build workflow

- Only trigger build on changes to main.go, cmd/, internal/, go.mod, go.sum
- Included .github/workflows/build-pulumigo.yml to allow workflow self-updates
- Schedule and manual dispatch remain available
This commit is contained in:
Haitao Pan 2025-05-19 11:48:46 +08:00
parent b0cff02470
commit c78a1ba6a1

88
.github/workflows/build-pulumigo.yml vendored Normal file
View File

@ -0,0 +1,88 @@
name: Build and Release PulumiGo CLI
on:
pull_request:
paths:
- 'PulumiGo/main.go'
- 'PulumiGo/go.mod'
- 'PulumiGo/go.sum'
- 'PulumiGo/cmd/**'
- 'PulumiGo/internal/**'
- '.github/workflows/build-pulumigo.yml'
push:
paths:
- 'PulumiGo/main.go'
- 'PulumiGo/go.mod'
- 'PulumiGo/go.sum'
- 'PulumiGo/cmd/**'
- 'PulumiGo/internal/**'
- '.github/workflows/build-pulumigo.yml'
schedule:
- cron: '0 2 * * *' # 每天 UTC 凌晨 2 点
workflow_dispatch:
jobs:
build-and-test:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
arch: [amd64, arm64]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build PulumiGo binary
run: |
mkdir -p dist
GOARCH=${{ matrix.arch }} GOOS=linux go build -o dist/PulumiGo-${{ matrix.os }}-${{ matrix.arch }} main.go
- name: Compress binary
run: |
cd dist
tar -czvf PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz PulumiGo-${{ matrix.os }}-${{ matrix.arch }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: pulumigo-${{ matrix.os }}-${{ matrix.arch }}
path: dist/PulumiGo-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
- name: Run CLI --help test
run: |
cd dist
tar -xzvf 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
runs-on: ubuntu-latest
env:
tag_name: daily-${{ github.run_id }}
release_name: Daily Build PulumiGo - ${{ github.run_number }}
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.tag_name }}
name: ${{ env.release_name }}
prerelease: true
files: release-artifacts/**/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}