diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99673d2..b8e80f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,76 +11,11 @@ jobs: run: make docker-test - name: build - run: make docker-build-static + run: make build-single-target - name: acceptance-test run: make docker-acceptance - - name: build-image - run: make docker-image - - - name: save image - run: make save-image - - - name: archive image - uses: actions/upload-artifact@v2 - with: - name: kubeconform-image - path: kubeconform-image.tar - - publish-image-master: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' - needs: test - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: Download kubeconform image - uses: actions/download-artifact@v2 - with: - name: kubeconform-image - - - name: load image - run: docker load < kubeconform-image.tar - - - name: push - run: | - echo "${{ github.token }}" | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin - make push-image - env: - RELEASE_VERSION: master - - publish-image-release: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') - needs: test - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: Download kubeconform image - uses: actions/download-artifact@v2 - with: - name: kubeconform-image - - - name: load image - run: docker load < kubeconform-image.tar - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: push-tag - run: | - echo "${{ github.token }}" | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin - make push-image - - - name: push-latest - run: | - make push-image - env: - RELEASE_VERSION: latest - goreleaser: runs-on: ubuntu-latest needs: test @@ -90,6 +25,8 @@ jobs: uses: actions/checkout@v2 - name: goreleaser - run: make release + run: | + echo "${{ github.token }}" | docker login https://ghcr.io -u ${GITHUB_ACTOR} --password-stdin + make release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index c24a370..2272dfc 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,22 +8,42 @@ builds: - windows - linux - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 flags: - -trimpath - -tags=netgo - -a ldflags: - -extldflags "-static" + archives: - format: tar.gz format_overrides: - goos: windows format: zip - name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" + name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" + +dockers: + - image_templates: + - 'ghcr.io/yannh/kubeconform:latest' + - 'ghcr.io/yannh/kubeconform:{{ .Tag }}' + - 'ghcr.io/yannh/kubeconform:{{ .Tag }}-amd64' + dockerfile: Dockerfile + build_flag_templates: + - "--platform=linux/amd64" + goos: linux + goarch: amd64 + checksum: name_template: 'CHECKSUMS' + snapshot: name_template: "{{ .Tag }}-next" + changelog: sort: asc filters: diff --git a/Dockerfile b/Dockerfile index 43f996c..df7f27d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,5 @@ RUN apk add ca-certificates FROM scratch AS kubeconform MAINTAINER Yann HAMON COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY bin/kubeconform / +COPY kubeconform / ENTRYPOINT ["/kubeconform"] diff --git a/Dockerfile.bats b/Dockerfile.bats index d7c29e6..7915050 100644 --- a/Dockerfile.bats +++ b/Dockerfile.bats @@ -1,5 +1,5 @@ FROM bats/bats:v1.2.1 RUN apk --no-cache add ca-certificates parallel -COPY bin/kubeconform /code/bin/ +COPY dist/kubeconform_linux_amd64/kubeconform /code/bin/ COPY acceptance.bats acceptance-nonetwork.bats /code/ COPY fixtures /code/fixtures diff --git a/Makefile b/Makefile index 979d499..c6223bc 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,12 @@ docker-acceptance: build-bats docker run -t bats -p acceptance.bats docker run --network none -t bats -p acceptance-nonetwork.bats +build-single-target: + docker run -t -e GOOS=linux -e GOARCH=amd64 -v $$PWD:/go/src/github.com/yannh/kubeconform -w /go/src/github.com/yannh/kubeconform goreleaser/goreleaser:v0.176.0 build --single-target --skip-post-hooks --rm-dist --snapshot + cp dist/kubeconform_linux_amd64/kubeconform bin/ + release: - docker run -e GITHUB_TOKEN -t -v $$PWD:/go/src/github.com/yannh/kubeconform -w /go/src/github.com/yannh/kubeconform goreleaser/goreleaser:v0.138 goreleaser release --rm-dist + docker run -e GITHUB_TOKEN -t -v /var/run/docker.sock:/var/run/docker.sock -v $$PWD:/go/src/github.com/yannh/kubeconform -w /go/src/github.com/yannh/kubeconform goreleaser/goreleaser:v0.176.0 release --rm-dist update-deps: go get -u ./...