2021-10-06 01:05:22 +02:00
# https://taskfile.dev
version : '3'
env :
GO111MODULE : on
GOPROXY : https://proxy.golang.org,direct
vars :
DOCKER : '{{default "docker" .DOCKER}}'
tasks :
dev :
2021-10-06 01:20:23 +02:00
desc : Setup git hooks
2021-10-06 01:05:22 +02:00
cmds :
- cp -f scripts/pre-commit.sh .git/hooks/pre-commit
setup :
desc : Install dependencies
cmds :
- go mod tidy
build :
desc : Build the binary
2021-10-06 04:23:19 +02:00
sources :
- ./**/*.go
generates :
- ./goreleaser
2021-10-06 01:05:22 +02:00
cmds :
- go build
test :
desc : Run tests
env :
LC_ALL : C
vars :
TEST_OPTIONS : '{{default "" .TEST_OPTIONS}}'
2021-10-06 01:22:26 +02:00
SOURCE_FILES : '{{default "./..." .SOURCE_FILES}}'
2021-10-06 01:05:22 +02:00
TEST_PATTERN : '{{default "." .TEST_PATTERN}}'
cmds :
- go test {{.TEST_OPTIONS}} -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt {{.SOURCE_FILES}} -run {{.TEST_PATTERN}} -timeout=5m
cover :
2021-10-06 01:20:23 +02:00
desc : Open the cover tool
2021-10-06 01:05:22 +02:00
cmds :
- go tool cover -html=coverage.txt
fmt :
2021-10-06 01:20:23 +02:00
desc : gofumpt all code
2021-10-06 01:05:22 +02:00
cmds :
- gofumpt -w -l -s .
2021-11-07 04:22:51 +02:00
lint :
desc : Lint the code with golangci-lint
cmds :
2021-11-21 16:10:54 +02:00
- golangci-lint run ./...
2021-11-07 04:22:51 +02:00
2021-10-06 01:05:22 +02:00
ci :
2021-10-06 01:39:24 +02:00
desc : Run all CI steps
2021-10-06 13:07:40 +02:00
cmds :
- task : setup
- task : build
- task : test
default :
desc : Runs the default tasks
cmds :
- task : ci
2021-10-06 01:05:22 +02:00
2021-11-18 15:01:31 +02:00
schema:generate :
desc : Generate JSONSchema
cmds :
- go run . schema -o ./www/docs/static/schema.json
sources :
- pkg/config/config.go
generates :
- ./www/docs/static/schema.json
2021-10-10 16:16:03 +02:00
docs:generate :
desc : Generate docs
cmds :
- cp -rf CONTRIBUTING.md www/docs/contributing.md
2021-10-30 14:43:54 +02:00
- cp -rf USERS.md www/docs/users.md
2021-10-10 16:16:03 +02:00
sources :
- CONTRIBUTING.md
2021-10-30 14:43:54 +02:00
- USERS.md
2021-10-10 16:16:03 +02:00
generates :
- www/docs/contributing.md
2021-10-30 14:43:54 +02:00
- www/docs/users.md
2021-10-10 16:16:03 +02:00
2021-10-06 01:20:23 +02:00
docs:imgs :
2021-10-06 01:05:22 +02:00
desc : Download and resize images
cmds :
2021-10-27 03:41:33 +02:00
- wget -O www/docs/static/logo.png https://raw.githubusercontent.com/goreleaser/artwork/master/goreleaserfundo.png
- wget -O www/docs/static/card.png https://raw.githubusercontent.com/goreleaser/artwork/master/twitter-card.png
2021-10-06 01:05:22 +02:00
- wget -O www/docs/static/avatar.png https://github.com/goreleaser.png
2021-10-06 01:46:59 +02:00
- convert www/docs/static/avatar.png -define icon:auto-resize=64,48,32,16 www/docs/static/favicon.ico
2021-10-06 01:05:22 +02:00
- convert www/docs/static/avatar.png -resize x120 www/docs/static/apple-touch-icon.png
docs:serve :
desc : Start documentation server
cmds :
2021-10-10 16:16:03 +02:00
- task : docs:generate
2021-11-14 17:27:43 +02:00
- '{{.DOCKER}} run --rm -p 8000:8000 -v ${PWD}/www:/docs docker.io/squidfunk/mkdocs-material'
2021-10-06 01:05:22 +02:00
2021-10-10 16:23:33 +02:00
docs:build :
desc : Build docs
cmds :
2021-10-10 16:24:55 +02:00
- task : docs:generate
2021-10-12 21:51:24 +02:00
- '{{.DOCKER}} run --rm -v ${PWD}/www:/docs docker.io/squidfunk/mkdocs-material build'
2021-10-10 16:23:33 +02:00
2021-10-06 01:20:23 +02:00
docs:vercel:build :
desc : Build documentation for deploying to Vercel
2021-10-06 01:05:22 +02:00
cmds :
2021-10-06 01:20:23 +02:00
- scripts/vercel/install.sh
- scripts/vercel/build.sh
2021-10-06 04:23:19 +02:00
release :
desc : Create a new tag
vars :
NEXT :
sh : svu n
cmds :
- git tag {{.NEXT}}
- echo {{.NEXT}}
- git push origin --tags
2021-11-14 03:23:11 +02:00
goreleaser:test:rpm :
desc : Tests rpm packages
cmds :
2021-11-14 17:27:43 +02:00
# no fedora nor centos with armv6 - docker run --platform linux/arm/6 --rm -v "$PWD/dist":/tmp/ centos:centos7 sh -c 'rpm --nodeps -ivh /tmp/goreleaser-*.arm6l.rpm && goreleaser --version'
- docker run --platform linux/386 --rm -v $PWD/dist:/tmp/ centos:centos7 sh -c 'rpm --nodeps -ivh /tmp/goreleaser-*.i386.rpm && goreleaser --version'
- docker run --platform linux/amd64 --rm -v "$PWD/dist":/tmp/ fedora sh -c 'rpm --nodeps -ivh /tmp/goreleaser-*.x86_64.rpm && goreleaser --version'
- docker run --platform linux/arm64 --rm -v "$PWD/dist":/tmp/ fedora sh -c 'rpm --nodeps -ivh /tmp/goreleaser-*.aarch64.rpm && goreleaser --version'
- docker run --platform linux/arm/6 --rm -v "$PWD/dist":/tmp/ fedora sh -c 'rpm --nodeps -ivh /tmp/goreleaser-*.armv6hl.rpm && goreleaser --version'
- docker run --platform linux/arm/7 --rm -v "$PWD/dist":/tmp/ fedora sh -c 'rpm --nodeps -ivh /tmp/goreleaser-*.armv7hl.rpm && goreleaser --version'
2021-11-14 03:23:11 +02:00
goreleaser:test:deb :
desc : Tests rpm packages
cmds :
2021-11-14 17:27:43 +02:00
- docker run --platform linux/amd64 --rm -v "$PWD/dist":/tmp/ ubuntu bash -c 'dpkg --ignore-depends=git -i /tmp/goreleaser*_amd64.deb && goreleaser --version'
- docker run --platform linux/arm64 --rm -v "$PWD/dist":/tmp/ ubuntu bash -c 'dpkg --ignore-depends=git -i /tmp/goreleaser*_arm64.deb && goreleaser --version'
- docker run --platform linux/arm/6 --rm -v "$PWD/dist":/tmp/ debian bash -c 'dpkg --ignore-depends=git -i /tmp/goreleaser*_armel.deb && goreleaser --version'
- docker run --platform linux/arm/7 --rm -v "$PWD/dist":/tmp/ ubuntu bash -c 'dpkg --ignore-depends=git -i /tmp/goreleaser*_armhf.deb && goreleaser --version'
2021-11-14 03:23:11 +02:00
goreleaser:test:apk :
desc : Tests rpm packages
cmds :
2021-11-14 17:27:43 +02:00
- docker run --platform linux/386 --rm -v "$PWD/dist":/tmp/ alpine ash -c 'apk add --allow-untrusted -U /tmp/goreleaser*_x86.apk && goreleaser --version'
- docker run --platform linux/amd64 --rm -v "$PWD/dist":/tmp/ alpine ash -c 'apk add --allow-untrusted -U /tmp/goreleaser*_x86_64.apk && goreleaser --version'
- docker run --platform linux/arm64 --rm -v "$PWD/dist":/tmp/ alpine ash -c 'apk add --allow-untrusted -U /tmp/goreleaser*_aarch64.apk && goreleaser --version'
- docker run --platform linux/arm/6 --rm -v "$PWD/dist":/tmp/ alpine ash -c 'apk add --allow-untrusted -U /tmp/goreleaser*_armhf.apk && goreleaser --version'
- docker run --platform linux/arm/7 --rm -v "$PWD/dist":/tmp/ alpine ash -c 'apk add --allow-untrusted -U /tmp/goreleaser*_armv7.apk && goreleaser --version'
2021-11-14 03:23:11 +02:00
goreleaser:test :
desc : Runs a local release and test some stuff
cmds :
- task : goreleaser:test:apk
- task : goreleaser:test:deb
- task : goreleaser:test:rpm
2021-10-06 04:23:19 +02:00
goreleaser :
desc : Run GoReleaser either in snapshot or release mode
deps :
- build
vars :
SNAPSHOT :
sh : 'if [[ $GITHUB_REF != refs/tags/v* ]]; then echo "--snapshot"; fi'
cmds :
- ./goreleaser release --rm-dist {{.SNAPSHOT}}