From 6c5591c9693a34aec5756b5382b035113e475523 Mon Sep 17 00:00:00 2001 From: Lena Fuhrimann <6780471+cloudlena@users.noreply.github.com> Date: Wed, 21 Apr 2021 11:02:51 +0200 Subject: [PATCH] Add GoReleaser config --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++ .gitignore | 1 + .goreleaser.yml | 12 +++++++++++ Dockerfile | 2 +- Makefile | 6 +++--- cmd/s3manager/main.go => main.go | 0 6 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml rename cmd/s3manager/main.go => main.go (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..558161d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + tags: + - "v*" + +jobs: + verify: + name: Verify + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ^1.16 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Lint code + uses: golangci/golangci-lint-action@v2 + with: + version: latest + + - name: Test + run: make test + + - name: Release + uses: goreleaser/goreleaser-action@v2 + with: + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 18b166a..1440505 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Binaries for programs and plugins bin/ +dist/ *.exe *.exe~ *.dll diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..4c4ba95 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,12 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +checksum: + name_template: "checksums.txt" diff --git a/Dockerfile b/Dockerfile index 696405a..b5c2b54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM docker.io/library/golang:1 AS builder WORKDIR /usr/src/app COPY . ./ -RUN CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager ./cmd/s3manager +RUN CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager FROM docker.io/library/alpine:latest WORKDIR /usr/src/app diff --git a/Makefile b/Makefile index d1631b3..b4b9c9f 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ .PHONY: build build: - go build -o bin/s3manager ./cmd/s3manager + go build -o bin/s3manager .PHONY: run run: - go run cmd/s3manager/main.go + go run .PHONY: lint lint: @@ -20,7 +20,7 @@ build-docker: .PHONY: deploy-cf deploy-cf: - GOOS=linux go build -ldflags="-s -w" -o bin/s3manager ./cmd/s3manager + GOOS=linux go build -ldflags="-s -w" -o bin/s3manager cf push -f deployments/cf/manifest.yml .PHONY: clean diff --git a/cmd/s3manager/main.go b/main.go similarity index 100% rename from cmd/s3manager/main.go rename to main.go