diff --git a/.github/workflows/build-pulumigo.yml b/.github/workflows/build-pulumigo.yml index 1911664f..8de98bdd 100644 --- a/.github/workflows/build-pulumigo.yml +++ b/.github/workflows/build-pulumigo.yml @@ -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 }} -