diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8757e59..0074ce4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,12 +18,23 @@ jobs: - name: checkout uses: actions/checkout@master with: - ref: ${{ github.ref }} + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.17 + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: build and test binary run: make ci - - name: docker build - run: make local-docker-build \ No newline at end of file + - name: GoReleaser Build + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --skip-publish --snapshot --rm-dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7779886..df48d4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,13 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: Docker Login uses: docker/login-action@v1 with: diff --git a/.gitignore b/.gitignore index eb0abc5..063ec93 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ .idea # Build / CI artifacts -bin +/ci-result-to-slack coverage.out diff --git a/.goreleaser.yml b/.goreleaser.yml index 1da8b63..d300ca1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,7 +2,6 @@ project_name: ci-result-to-slack builds: - env: [CGO_ENABLED=0] main: ./cmd/ci-result-to-slack - binary: bin/ci-result-to-slack goos: - linux - windows diff --git a/Dockerfile b/Dockerfile index e2ca579..2647819 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM gcr.io/distroless/base-debian11 -COPY ./bin/ci-result-to-slack /ci-result-to-slack +COPY ./ci-result-to-slack /ci-result-to-slack ENTRYPOINT ["/ci-result-to-slack"] diff --git a/Makefile b/Makefile index 0d169d2..013b606 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ ci: build test build: clean @echo "Building..." - CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o bin/$(BINARY_NAME) ./cmd/$(BINARY_NAME)/main.go + CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o $(BINARY_NAME) ./cmd/$(BINARY_NAME)/main.go test: clean @echo "Running unit tests..." @@ -23,7 +23,7 @@ lint: clean: @echo "Cleaning..." - rm -rf ./bin/$(BINARY_NAME) + rm -rf .$(BINARY_NAME) rm -rf coverage.out local-docker-test: ## Build and run unit tests in docker container like CI without building the container