CI/CD - Build, Test and Release #25
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 | |
| # TODO: consider using upx to further minimize binary size | |
| name: CI/CD - Build, Test and Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| architecture: [amd64, arm64, 386, riscv64] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.23' | |
| - name: Run tests | |
| run: go test -v ./... | |
| - name: Build | |
| run: | | |
| GOARCH=${{ matrix.architecture }} GOOS=linux go build -ldflags="-s -w" -v -o kman-${{ matrix.architecture }} ./cmd/kman/kman.go | |
| - name: Display structure of files | |
| run: ls -lRha | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: kman-${{ matrix.architecture }} | |
| path: kman-${{ matrix.architecture }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| with: | |
| files: | | |
| kman-amd64 | |
| kman-arm64 | |
| kman-386 | |
| kman-riscv64 | |
| token: ${{ secrets.RELEASE_PAT }} | |