Update goreleaser

This commit is contained in:
Yann Hamon 2021-08-29 10:53:39 +02:00
parent ab7fd7f97d
commit ec52b39db3
5 changed files with 32 additions and 71 deletions

View file

@ -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 }}

View file

@ -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:

View file

@ -4,5 +4,5 @@ RUN apk add ca-certificates
FROM scratch AS kubeconform
MAINTAINER Yann HAMON <yann@mandragor.org>
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY bin/kubeconform /
COPY kubeconform /
ENTRYPOINT ["/kubeconform"]

View file

@ -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

View file

@ -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 ./...