Skip to content

Commit

Permalink
chore: Use goreleaser from go-tools; Update go-tools to v0.13.0 (#101)
Browse files Browse the repository at this point in the history
* chore: Update go-tools to v0.12.1

* fix: goreleaser config

* chore: Remove depguard linter from configs

* chore: Refactor release scripts

* chore: Bump go-tools version to v0.13.0

* refactor: Use goreleaser from go-tools

* ci: Fix after goreleaser usage refactor
  • Loading branch information
obalunenko authored Aug 1, 2023
1 parent c91c3c4 commit d03efe0
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 47 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ jobs:
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ jobs:
make build
shell: bash

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
install-only: true

- name: Check release
run: |
make check-releaser
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ jobs:
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
echo "${GITHUB_TOKEN}" | docker login ghcr.io --username $GITHUB_ACTOR --password-stdin
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
install-only: true

- name: Run GoReleaser
if: success()
env:
Expand Down
9 changes: 0 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by github.com/obalunenko/logger"
dupl:
threshold: 100
funlen:
Expand Down Expand Up @@ -56,7 +48,6 @@ linters:
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
Expand Down
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ archives:
- id: service
builds:
- service
rlcp: true
format: tar.gz
wrap_in_directory: true
format_overrides:
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))
APP_NAME?=scrum-report
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)

GOTOOLS_IMAGE_TAG?=v0.10.0
GOTOOLS_IMAGE_TAG?=v0.13.0
SHELL := env GOTOOLS_IMAGE_TAG=$(GOTOOLS_IMAGE_TAG) $(SHELL)

COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml
COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE)
COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --exit-code-from
COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --remove-orphans --exit-code-from
COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) pull

TARGET_MAX_CHAR_NUM=20
Expand All @@ -40,12 +40,12 @@ help:


## Build project.
build: compile-app
build: sync-vendor generate compile-app
.PHONY: build

## Compile app.
compile-app:
./scripts/build/app.sh
$(COMPOSE_TOOLS_CMD_UP) build build
.PHONY: compile-app

## Test coverage report.
Expand Down Expand Up @@ -106,7 +106,7 @@ install-tools:

## vet project
vet:
./scripts/linting/run-vet.sh
$(COMPOSE_TOOLS_CMD_UP) vet vet
.PHONY: vet

## Run full linting
Expand Down Expand Up @@ -135,17 +135,17 @@ generate: codegen format-project vet

## Release
release:
./scripts/release/release.sh
$(COMPOSE_TOOLS_CMD_UP) release release
.PHONY: release

## Release local snapshot
release-local-snapshot:
./scripts/release/local-snapshot-release.sh
$(COMPOSE_TOOLS_CMD_UP) release-local-snapshot release-local-snapshot
.PHONY: release-local-snapshot

## Check goreleaser config.
check-releaser:
./scripts/release/check.sh
$(COMPOSE_TOOLS_CMD_UP) release-check-config release-check-config
.PHONY: check-releaser

## Issue new release.
Expand Down
58 changes: 51 additions & 7 deletions deployments/docker-compose/go-tools-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@ services:
- ../../:/app/
command: /bin/sh -c ''

vet:
extends:
service: tools
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/linting/run-vet.sh'

fix-imports:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/style/fix-imports.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/style/fix-imports.sh'

fix-fmt:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/style/fmt.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/style/fmt.sh'

run-tests:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/tests/run.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/tests/run.sh'

run-tests-coverage:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/tests/coverage.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/tests/coverage.sh'

prepare-cover-report:
extends:
Expand All @@ -36,12 +41,12 @@ services:
update-readme-coverage:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/update-readme-coverage.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/update-readme-coverage.sh'

lint-full:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/linting/run-linters.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/linting/run-linters.sh'

lint-pipeline:
extends:
Expand All @@ -56,4 +61,43 @@ services:
go-generate:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/codegen/go-generate.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/codegen/go-generate.sh'

build:
extends:
service: tools
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/build/app.sh'
environment:
APP_NAME: ${APP_NAME}
GOOS: ${GOOS}
GOARCH: ${GOARCH}

release-local-snapshot:
extends:
service: tools
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/release/local-snapshot-release.sh'
environment:
APP_NAME: ${APP_NAME}
GOOS: ${GOOS}
GOARCH: ${GOARCH}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
volumes:
- /var/run/docker.sock:/var/run/docker.sock

release-check-config:
extends:
service: tools
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/release/check.sh'
environment:
APP_NAME: ${APP_NAME}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}

release:
extends:
service: tools
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/release/release.sh'
environment:
APP_NAME: ${APP_NAME}
GITHUB_TOKEN: ${GITHUB_TOKEN:-}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
5 changes: 1 addition & 4 deletions scripts/release/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ echo "${SCRIPT_NAME} is running fo ${APP}... "

checkInstalled 'goreleaser'

# Get new tags from the remote
git fetch --tags -f
goreleaser healthcheck

COMMIT="$(git rev-parse HEAD)"
SHORTCOMMIT="$(git rev-parse --short HEAD)"
Expand All @@ -40,5 +39,3 @@ export GO_BUILD_LDFLAGS="-s -w \
-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}"

goreleaser check

goreleaser build --rm-dist --single-target --snapshot
5 changes: 2 additions & 3 deletions scripts/release/local-snapshot-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ echo "${SCRIPT_NAME} is running fo ${APP}... "

checkInstalled 'goreleaser'

# Get new tags from the remote
git fetch --tags -f
goreleaser healthcheck

COMMIT="$(git rev-parse HEAD)"
SHORTCOMMIT="$(git rev-parse --short HEAD)"
Expand All @@ -39,4 +38,4 @@ export GO_BUILD_LDFLAGS="-s -w \
-X ${BUILDINFO_VARS_PKG}.appname=${APP} \
-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}"

goreleaser --snapshot --skip-publish --rm-dist
goreleaser --snapshot --skip-publish --clean
7 changes: 3 additions & 4 deletions scripts/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ echo "${SCRIPT_NAME} is running... "

checkInstalled 'goreleaser'

goreleaser healthcheck

APP=${APP_NAME}

echo "${SCRIPT_NAME} is running fo ${APP}... "

# Get new tags from the remote
git fetch --tags -f

COMMIT="$(git rev-parse HEAD)"
SHORTCOMMIT="$(git rev-parse --short HEAD)"
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
Expand All @@ -39,4 +38,4 @@ export GO_BUILD_LDFLAGS="-s -w \
-X ${BUILDINFO_VARS_PKG}.appname=${APP} \
-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}"

goreleaser release --rm-dist
goreleaser release --clean

0 comments on commit d03efe0

Please sign in to comment.