ci(build): multi-arch and multi-os build #28
This file contains 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
name: Continous Integration | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
golangci-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
cache: false | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Run tests | |
run: go test -v ./... | |
env: | |
CGO_ENABLED: 0 | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: | |
- linux | |
- darwin | |
goarch: | |
- amd64 | |
- arm64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create GitHub App Token | |
uses: actions/create-github-app-token@v1 | |
id: token | |
with: | |
app-id: ${{ secrets.RELEASE_PLEASE_APP_ID }} | |
private-key: ${{ secrets.RELEASE_PLEASE_PRIVATE_KEY }} | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Build | |
run: go build -buildvcs=true -o ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/kubectl-mapr-ticket ./cmd/kubectl-mapr-ticket | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
CGO_ENABLED: 0 | |
- name: Compress | |
run: | | |
tar -czvf \ | |
./kubectl-mapr-ticket-${{ matrix.goarch }}-${{ matrix.goos }}.tar.gz \ | |
-C ./bin/${{ matrix.goarch }}/${{ matrix.goos }}/ \ | |
kubectl-mapr-ticket | |
- name: Upload artifact | |
if: contains(github.ref, 'tags') | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ steps.token.outputs.token }} | |
file: ./kubectl-mapr-ticket-${{ matrix.goarch }}-${{ matrix.goos }}.tar.gz | |
tag: ${{ github.ref }} | |
overwrite: true |