From 5dec723779aaeb6a76267e1e6b5c4334ff9ebf57 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:23:07 +0100 Subject: [PATCH] ci: add release pipeline (#2) --- .chglog/CHANGELOG.tpl.md | 23 ++++++++++++++++ .chglog/config.yml | 25 ++++++++++++++++++ .drone.yml | 57 +++++++++++++++++++++++++++++++++++++--- .tflint.hcl | 16 +++++++++++ variables.tf | 1 + 5 files changed, 119 insertions(+), 3 deletions(-) create mode 100755 .chglog/CHANGELOG.tpl.md create mode 100755 .chglog/config.yml create mode 100644 .tflint.hcl diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md new file mode 100755 index 0000000..cc0367b --- /dev/null +++ b/.chglog/CHANGELOG.tpl.md @@ -0,0 +1,23 @@ +# Changelog + +{{ range .Versions -}} +## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) + +{{ range .CommitGroups -}} +### {{ .Title }} + +{{ range .Commits -}} +- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ (regexReplaceAll "(.*)/issues/(.*)" (regexReplaceAll "(Co-\\w*-by.*)" .Subject "") "${1}/pulls/${2}") | trim }} +{{ end }} +{{- end -}} + +{{- if .NoteGroups -}} +{{ range .NoteGroups -}} +### {{ .Title }} + +{{ range .Notes }} +{{ .Body }} +{{ end }} +{{ end -}} +{{ end -}} +{{ end -}} diff --git a/.chglog/config.yml b/.chglog/config.yml new file mode 100755 index 0000000..c7478ba --- /dev/null +++ b/.chglog/config.yml @@ -0,0 +1,25 @@ +style: github +template: CHANGELOG.tpl.md +info: + title: CHANGELOG + repository_url: https://gitea.rknet.org/infra/hcloud-server-tf +options: + commit_groups: + title_maps: + feat: Features + fix: Bug Fixes + perf: Performance Improvements + refactor: Code Refactoring + chore: Others + test: Testing + ci: CI Pipeline + docs: Documentation + header: + pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" + pattern_maps: + - Type + - Scope + - Subject + notes: + keywords: + - BREAKING CHANGE diff --git a/.drone.yml b/.drone.yml index c9ba5c6..41785bb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -name: check +name: test platform: os: linux @@ -13,13 +13,18 @@ steps: commands: - git diff-tree --check $(git hash-object -t tree /dev/null) HEAD + - name: tflint + image: ghcr.io/terraform-linters/tflint + commands: + - tflint --color + - name: terraform pull: always image: jmccann/drone-terraform:8 settings: actions: - validate - tf_version: 1.2.0 + tf_version: 1.3.0 node: zone: mgmt @@ -30,8 +35,54 @@ trigger: - refs/tags/** - refs/pull/** +--- +kind: pipeline +name: release + +platform: + os: linux + arch: amd64 + +steps: + - name: changelog-generate + image: thegeeklab/git-chglog + commands: + - git fetch -tq + - git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased} + + - name: changelog-format + image: thegeeklab/alpine-tools + commands: + - prettier CHANGELOG.md + - prettier -w CHANGELOG.md + + - name: publish-gitea + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_token + base_url: https://gitea.rknet.org + note: CHANGELOG.md + overwrite: true + title: ${DRONE_TAG} + when: + ref: + - refs/tags/** + +node: + zone: mgmt + +trigger: + ref: + - refs/heads/main + - refs/pull/** + - refs/tags/** + +depends_on: + - test + --- kind: signature -hmac: ec825d5879e3dc1d26bdc619143cf2ea41d5183c2d7b892498b21103379675c2 +hmac: 08a182381788120a9debba89ce838da455d72b0057be6bd1b84ae3437eb1106d ... diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..299bcc6 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,16 @@ +plugin "terraform" { + enabled = true + preset = "recommended" +} + +rule "terraform_required_version" { + enabled = false +} + +rule "terraform_required_providers" { + enabled = false +} + +rule "terraform_unused_declarations" { + enabled = false +} diff --git a/variables.tf b/variables.tf index 2151588..104988a 100644 --- a/variables.tf +++ b/variables.tf @@ -39,6 +39,7 @@ variable "ucs_zones" { // Module variable "server" { + type = list(any) default = [] }