使用go-task替代Makefile执行流水线构建任务
- 2025-04-22 22:22:00
- 丁国栋
- 原创 270
go-task
官方介绍:Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.
项目地址:https://github.com/go-task/task
安装:https://taskfile.dev/installation/
手册:https://taskfile.dev/usage/
配置文件:Taskfile.yml
常用配置:
# https://taskfile.dev
version: '3'
env:
EXAMPLE_VAR: example
APP_VER:
sh: echo 1.$(date +%y%m%d).$(git log --since=midnight --pretty=oneline | wc -l | awk '{$1=$1};1')
GIT_REF:
sh: echo $(git rev-parse --short HEAD)
tasks:
default:
cmds:
- oneline-command
- |
multiple-lines-comand1 \
--arg APP_VER="{{.APP_VER}}" \
--arg GIT_REF={{.GIT_REF}} \
anything-else
- |
multiple-lines-comand2 \
--arg APP_VER="{{.APP_VER}}" \
--arg GIT_REF={{.GIT_REF}} \
anything-else
named-task:
cmds:
- |
multiple-lines-comand \
--arg APP_VER="{{.APP_VER}}" \
--arg GIT_REF={{.GIT_REF}} \
anything-else
一个更简洁的例子
# https://taskfile.dev
version: '3'
env:
tasks:
default:
cmds:
- docker build --push -f Dockerfile -t hub.thedf.cc/test/php:7.4.33-apache .
--
发表评论