diff --git a/.woodpecker/pr.yml b/.woodpecker/pr.yml new file mode 100644 index 0000000..8fc7ed6 --- /dev/null +++ b/.woodpecker/pr.yml @@ -0,0 +1,26 @@ +when: + event: pull_request + branch: main + + +matrix: + include: + - IMAGE: golang:1.20-alpine + PACKAGE_MANAGER: apk + INSTALL_CMD: "add --no-cache" + PACKAGE: "make alpine-sdk g++" + - IMAGE: golang:latest + PACKAGE_MANAGER: apt + INSTALL_CMD: "upgrade -y" + PACKAGE: "" + +steps: + prepare-build: + image: ${IMAGE} + commands: + - ${PACKAGE_MANAGER} update + - ${PACKAGE_MANAGER} ${INSTALL_CMD} ${PACKAGE} + - make dep + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 + - make lint + - make fmt diff --git a/.woodpecker/release.yml b/.woodpecker/release.yml new file mode 100644 index 0000000..41e8c8e --- /dev/null +++ b/.woodpecker/release.yml @@ -0,0 +1,27 @@ +when: + event: tag + branch: main + +steps: + build: + image: golang:1.20-alpine + commands: + - apk update + - apk add --no-cache make alpine-sdk g++ + - make build + - echo "$${CI_COMMIT_TAG}" + - make release + + release: + image: woodpeckerci/plugin-gitea-release + settings: + base_url: https://git.iratusmachina.com + files: + - "artifacts/*.tar.gz" + file-exists: overwrite + api_key: + from_secret: gitea_release_token + draft: true + skip_verify: true + target: main + checksum: sha256 diff --git a/Makefile b/Makefile index fcd66ba..9a5f40c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,15 @@ # Inspired from https://dustinspecker.com/posts/go-combined-unit-integration-code-coverage/ and https://netdevops.me/2023/test-coverage-for-go-integration-tests/ -BIN_DIR = $(CURDIR)/bin +BIN_DIR = $(CURDIR)/artifacts BINARY = $(BIN_DIR)/lyricdownloader +CURRENT_DIR = $(shell pwd) +CUR_TAG = $(shell git tag | sort -g | tail -1 | cut -c 2-) +VERSION_NUMBER ?= 0.0.0 + +ifneq ($(CI_COMMIT_TAG),) + VERSION_NUMBER := $(CI_COMMIT_TAG:v%=%) +else + VERSION_NUMBER := ${CUR_TAG} +endif .PHONY: clean clean: @@ -22,6 +31,17 @@ lint: build: go build -o $(BINARY) +.PHONY: release +release: + mv ${BINARY} ${BINARY}-${VERSION_NUMBER} + cd ${BIN_DIR} + mkdir ${BIN_DIR}/tmp + mv ${BINARY}-${VERSION_NUMBER} ${BIN_DIR}/tmp + # From here https://www.baeldung.com/linux/tar-archive-without-directory-structure + tar -zcvf ${BINARY}-${VERSION_NUMBER}.tar.gz -C ${BIN_DIR}/tmp . + rm -rf ${BIN_DIR}/tmp + cd ${CURRENT_DIR} + .PHONY: lint-all lint-all: golangci-lint run --enable-all