From c78a1ba6a133660fa0fc49275b8f1660c48a2630 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Mon, 19 May 2025 11:48:46 +0800 Subject: [PATCH] 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 --- .github/workflows/build-pulumigo.yml | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/build-pulumigo.yml diff --git a/.github/workflows/build-pulumigo.yml b/.github/workflows/build-pulumigo.yml new file mode 100644 index 00000000..1911664f --- /dev/null +++ b/.github/workflows/build-pulumigo.yml @@ -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 }} +