From 358a2688e330697fd334e73853e6ed19382df293 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:03:26 +0100 Subject: [PATCH 1/7] ci: add release pipeline --- .chglog/CHANGELOG.tpl.md | 23 +++++++++++++++ .chglog/config.yml | 25 ++++++++++++++++ .drone.yml | 61 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 106 insertions(+), 3 deletions(-) create mode 100755 .chglog/CHANGELOG.tpl.md create mode 100755 .chglog/config.yml 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..d582c7e 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,58 @@ 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} + depends_on: + - tags + + - name: changelog-format + image: thegeeklab/alpine-tools + commands: + - prettier CHANGELOG.md + - prettier -w CHANGELOG.md + depends_on: + - changelog-generate + + - 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/** + depends_on: + - publish-dockerhub + - publish-quay + +trigger: + ref: + - refs/heads/main + - refs/pull/** + - refs/tags/** + +depends_on: + - test + --- kind: signature -hmac: ec825d5879e3dc1d26bdc619143cf2ea41d5183c2d7b892498b21103379675c2 +hmac: 8811fe550ab6c86d00c61525cfb9decaf56d324633c3a7171057d2f12cf5b86d ... -- 2.24.4 From 6a7352879a868318518b544831816ba7327bf802 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:07:25 +0100 Subject: [PATCH 2/7] add tflint config file --- .tflint.hcl | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .tflint.hcl diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..1d1b707 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,12 @@ +plugin "terraform" { + enabled = true + preset = "recommended" +} + +rule "terraform_required_version" { + enabled = disabled +} + +rule "terraform_required_providers" { + enabled = disabled +} -- 2.24.4 From 7d36bdc99808a3d63880987ef7c8bccb9724e79e Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:08:29 +0100 Subject: [PATCH 3/7] fix release pipeline --- .drone.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index d582c7e..3cd15a5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -49,16 +49,12 @@ steps: commands: - git fetch -tq - git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased} - depends_on: - - tags - name: changelog-format image: thegeeklab/alpine-tools commands: - prettier CHANGELOG.md - prettier -w CHANGELOG.md - depends_on: - - changelog-generate - name: publish-gitea image: plugins/gitea-release @@ -72,9 +68,6 @@ steps: when: ref: - refs/tags/** - depends_on: - - publish-dockerhub - - publish-quay trigger: ref: @@ -87,6 +80,6 @@ depends_on: --- kind: signature -hmac: 8811fe550ab6c86d00c61525cfb9decaf56d324633c3a7171057d2f12cf5b86d +hmac: 3ecadad3cee7f0d3431ef14117996741a4c4d7bbfa94adc16c009556ccc3f4c0 ... -- 2.24.4 From dd4b13c844ca2ccb900a1bf6f5ade0011dbd275c Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:10:30 +0100 Subject: [PATCH 4/7] fix tflint config --- .tflint.hcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tflint.hcl b/.tflint.hcl index 1d1b707..1fdcf2b 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -4,9 +4,9 @@ plugin "terraform" { } rule "terraform_required_version" { - enabled = disabled + enabled = false } rule "terraform_required_providers" { - enabled = disabled + enabled = false } -- 2.24.4 From ad0e40e3546c7b48ab9f98769be7aaec0d95e300 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:17:25 +0100 Subject: [PATCH 5/7] allow unused declarations --- .tflint.hcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.tflint.hcl b/.tflint.hcl index 1fdcf2b..299bcc6 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -10,3 +10,7 @@ rule "terraform_required_version" { rule "terraform_required_providers" { enabled = false } + +rule "terraform_unused_declarations" { + enabled = false +} -- 2.24.4 From ea20dd8b77e16a643ce82d02c14c722c8a897b27 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:19:32 +0100 Subject: [PATCH 6/7] add missing var type --- variables.tf | 1 + 1 file changed, 1 insertion(+) 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 = [] } -- 2.24.4 From f4ee30e7b26a9453fb26ace849b9fb1fd58c0ffc Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 18 Dec 2022 16:21:55 +0100 Subject: [PATCH 7/7] add missing zone to ci config --- .drone.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3cd15a5..41785bb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -69,6 +69,9 @@ steps: ref: - refs/tags/** +node: + zone: mgmt + trigger: ref: - refs/heads/main @@ -80,6 +83,6 @@ depends_on: --- kind: signature -hmac: 3ecadad3cee7f0d3431ef14117996741a4c4d7bbfa94adc16c009556ccc3f4c0 +hmac: 08a182381788120a9debba89ce838da455d72b0057be6bd1b84ae3437eb1106d ... -- 2.24.4