github.com/spinnaker/spin@v1.30.0/.github/workflows/pr.yml (about)

     1  name: PR Build
     2  
     3  on: [ pull_request ]
     4  
     5  env:
     6    CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker
     7  
     8  jobs:
     9    lint:
    10      runs-on: ubuntu-latest
    11      steps:
    12      - name: Checkout code
    13        uses: actions/checkout@v3
    14      - uses: actions/setup-go@v4
    15        with:
    16          go-version-file: go.mod
    17          cache: false
    18      - name: Ensure code formatting and style is consistent
    19        uses: golangci/golangci-lint-action@v3
    20        with:
    21          version: v1.45.2
    22  
    23    build:
    24      runs-on: ubuntu-latest
    25      steps:
    26        - uses: actions/checkout@v3
    27        - name: Prepare build variables
    28          id: build_variables
    29          run: |
    30            echo REPO="${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT
    31            echo VERSION="$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
    32  
    33        - uses: actions/setup-go@v4
    34          with:
    35            go-version-file: go.mod
    36            cache: false
    37        - uses: actions/cache@v3
    38          with:
    39            path: ~/go/pkg/mod
    40            key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    41            restore-keys: |
    42              ${{ runner.os }}-go-
    43        - name: Fetch dependencies
    44          run: go get -d -v
    45        - name: Test
    46          run: go test -v ./...
    47        - name: Build binaries
    48          env:
    49            LDFLAGS: "-X github.com/spinnaker/spin/version.Version=${{ steps.build_variables.outputs.VERSION }}"
    50          run: |
    51            GOARCH=amd64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/darwin/amd64/spin .
    52            GOARCH=amd64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/linux/amd64/spin .
    53            GOARCH=arm64 GOOS=linux go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/linux/arm64/spin .
    54            GOARCH=amd64 GOOS=windows go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/windows/amd64/spin.exe .
    55            GOARCH=arm64 GOOS=darwin go build -ldflags "${LDFLAGS}" -o dist/${{ steps.build_variables.outputs.VERSION }}/darwin/arm64/spin .
    56            dist/${{ steps.build_variables.outputs.VERSION }}/linux/amd64/spin --version
    57  
    58        - name: Build container image
    59          uses: docker/build-push-action@v4
    60          with:
    61            context: .
    62            file: Dockerfile
    63            push: false
    64            build-args: |
    65              "VERSION=${{ steps.build_variables.outputs.VERSION }}"
    66            tags: |
    67              "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest"
    68              "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"