|
| 1 | +name: Release CLI Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: # Allow manual trigger |
| 8 | + |
| 9 | +env: |
| 10 | + GO_VERSION: 1.24.1 |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release-cli: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + - goos: linux |
| 22 | + goarch: amd64 |
| 23 | + - goos: linux |
| 24 | + goarch: arm64 |
| 25 | + - goos: darwin |
| 26 | + goarch: amd64 |
| 27 | + - goos: darwin |
| 28 | + goarch: arm64 |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Set up Go |
| 36 | + uses: actions/setup-go@v5 |
| 37 | + with: |
| 38 | + go-version: ${{ env.GO_VERSION }} |
| 39 | + |
| 40 | + - name: Get version info |
| 41 | + id: version |
| 42 | + run: | |
| 43 | + TAG=${GITHUB_REF#refs/tags/} |
| 44 | + GIT_COMMIT=$(git rev-parse HEAD) |
| 45 | + BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z) |
| 46 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 47 | + echo "git_commit=$GIT_COMMIT" >> $GITHUB_OUTPUT |
| 48 | + echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT |
| 49 | +
|
| 50 | + - name: Build CLI binary |
| 51 | + env: |
| 52 | + GOOS: ${{ matrix.goos }} |
| 53 | + GOARCH: ${{ matrix.goarch }} |
| 54 | + CGO_ENABLED: '0' |
| 55 | + run: | |
| 56 | + VERSION_PKG=sigs.k8s.io/rbgs/version |
| 57 | + LDFLAGS="-s -w -X ${VERSION_PKG}.Version=${{ steps.version.outputs.tag }} -X ${VERSION_PKG}.GitCommit=${{ steps.version.outputs.git_commit }} -X ${VERSION_PKG}.BuildDate=${{ steps.version.outputs.build_date }}" |
| 58 | + BINARY_NAME=kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }} |
| 59 | + go build -mod vendor -v -o ${BINARY_NAME} -ldflags "${LDFLAGS}" cmd/cli/main.go |
| 60 | + chmod +x ${BINARY_NAME} |
| 61 | +
|
| 62 | + # Generate checksum |
| 63 | + sha256sum ${BINARY_NAME} > ${BINARY_NAME}.sha256 |
| 64 | +
|
| 65 | + - name: Upload artifact |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }} |
| 69 | + path: | |
| 70 | + kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }} |
| 71 | + kubectl-rbg-${{ matrix.goos }}-${{ matrix.goarch }}.sha256 |
| 72 | +
|
| 73 | + create-release: |
| 74 | + needs: release-cli |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - name: Download all artifacts |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + path: artifacts |
| 81 | + merge-multiple: true |
| 82 | + |
| 83 | + - name: Create GitHub Release |
| 84 | + uses: softprops/action-gh-release@v2 |
| 85 | + with: |
| 86 | + generate_release_notes: true |
| 87 | + files: | |
| 88 | + artifacts/kubectl-rbg-* |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments