Adding woodpecker build files #1

Merged
iratusmachina merged 1 commits from feature/woodpecker into main 2024-04-06 19:48:18 +00:00
3 changed files with 74 additions and 1 deletions

26
.woodpecker/pr.yml Normal file
View File

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

27
.woodpecker/release.yml Normal file
View File

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

View File

@ -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/ # 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 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 .PHONY: clean
clean: clean:
@ -22,6 +31,17 @@ lint:
build: build:
go build -o $(BINARY) 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 .PHONY: lint-all
lint-all: lint-all:
golangci-lint run --enable-all golangci-lint run --enable-all