Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
142 lines (124 loc) · 3.95 KB
/
Copy pathTaskfile.yml
File metadata and controls
142 lines (124 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
version: '3'
env:
TERM: screen-256color
dotenv:
- ".env.local"
tasks:
default:
desc: List all tasks
cmds:
- task --list-all
test:
desc: Run tests.
cmds:
- task: test-go
- task: test-terraform
clean:
desc: Clean the environment.
cmds:
- task: clean-go
- task: clean-terraform
clean-go:
desc: Clean the go environment (go mod tidy)
cmds:
- go mod tidy
terraform-docs:
desc: Update terraform docs
preconditions:
- sh: test -f ".terraform-docs.yml"
msg: '.terraform-docs.yml required. Run "task generate-terraform-docs-config" to create it.'
cmds:
- cat .terraform-docs.yml
- terraform-docs .
generate-terraform-docs-config:
desc: Generate terraform docs configuration
cmds:
- |
cat << EOF > .terraform-docs.yml
formatter: "markdown table"
sort:
by: required
output:
file: README.md
settings:
hide-empty: true
lockfile: false
EOF
clean-terraform:
desc: Clean the terraform environment (remove terraform directories and files)
cmds:
- find . -type d -name .terraform -exec rm -rf {} +
- find . -type f -name .terraform.lock.hcl -delete
test-go:
desc: Run tests for all Go code.
silent: true
cmds:
- go fmt ./...
- go vet -v ./...
test-terraform:
desc: Run tests for all terraform directories.
silent: true
env:
DIRECTORIES:
sh: find . -path '*/.terraform/*' -prune -o -name '*.tf' -type f -exec dirname {} \; | sort -u
cmds:
- |
BOLD=$(tput bold)
NORM=$(tput sgr0)
CWD=$PWD
for d in $DIRECTORIES; do
cd $d
echo "${BOLD}$PWD:${NORM}"
if ! terraform fmt -check=true -list=false -recursive=false; then
echo " ✗ terraform fmt" && exit 1
else
echo " √ terraform fmt"
fi
if ! terraform init -backend=false -input=false -get=true -no-color > /dev/null; then
echo " ✗ terraform init" && exit 1
else
echo " √ terraform init"
fi
if ! terraform validate > /dev/null; then
echo " ✗ terraform validate" && exit 1
else
echo " √ terraform validate"
fi
cd $CWD
done
release:
desc: Create a new release.
preconditions:
- sh: test -x "$(which gh 2>/dev/null)"
msg: 'GH CLI required. See https://cli.github.com/.'
- sh: test -n "{{.MOD_RELEASE}}"
msg: 'MOD_RELEASE environment variable required. MOD_RELEASE should be a semver tag like `1.2.3`` and greater than current tag {{.SEMVER_TAG}}. either pass with `MOD_RELEASE=1.2.3 task release` or set in .env.local file.'
vars:
MOD_REPO:
sh: echo "${PWD##*/}"
REPO_OWNER:
sh: git config --local remote.origin.url | cut -d':' -f2 | cut -d'/' -f1
SEMVER_TAG:
sh: git describe --tags --abbrev=0
env:
MOD_RELEASE: '{{.MOD_RELEASE}}'
cmds:
- |
export MOD_REPO="{{.MOD_REPO}}"
export MOD_RELEASE="{{.MOD_RELEASE}}"
export REPO_OWNER="{{.REPO_OWNER}}"
echo "Releasing {{.REPO_OWNER}}/{{.MOD_REPO}} version {{.MOD_RELEASE}}"
- git checkout -b rel-${MOD_RELEASE}
- |
python .github/scripts/markdown-url-converter/markdown-url-converter.py --repo="{{.REPO_OWNER}}/{{.MOD_REPO}}" --release="{{.MOD_RELEASE}}" --overwrite .
- git commit --allow-empty -am "Release version ${MOD_RELEASE}"
- git tag -a ${MOD_RELEASE} -m "${MOD_RELEASE} release"
- git revert HEAD --no-edit
- git push origin --tags
- git push origin rel-${MOD_RELEASE}
- |
gh release create {{.MOD_RELEASE}} \
--repo {{.REPO_OWNER}}/{{.MOD_REPO}} \
--title "{{.MOD_RELEASE}}" \
--generate-notes --verify-tag
- git push origin --delete rel-${MOD_RELEASE}