From f0990aec59b2be8f51ccafed940eae195457e8f4 Mon Sep 17 00:00:00 2001 From: Timo Furrer <tfurrer@gitlab.com> Date: Wed, 27 Mar 2024 10:07:02 +0100 Subject: [PATCH] Introduce changelog and release make target --- .gitlab/README.md.template | 3 ++- .gitlab/changelog_config.yml | 14 ++++++++++++++ .gitlab/release-notes.md.template | 2 ++ CONTRIBUTING.md | 6 ++++++ Makefile | 14 ++++++++++++++ README.md | 3 ++- 6 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .gitlab/changelog_config.yml diff --git a/.gitlab/README.md.template b/.gitlab/README.md.template index e6fd881..2a9d0ad 100644 --- a/.gitlab/README.md.template +++ b/.gitlab/README.md.template @@ -208,7 +208,8 @@ plan: ## Releases & Versioning This project currently releases tagged commits. -An overview of releases can be found on the [Releases page](https://gitlab.com/components/opentofu/-/releases). +An overview of releases can be found on the [Releases page](https://gitlab.com/components/opentofu/-/releases) +and a Changelog can be found [here](CHANGELOG.md). Each release is accessible in the [CI/CD Catalog](https://gitlab.com/explore/catalog). diff --git a/.gitlab/changelog_config.yml b/.gitlab/changelog_config.yml new file mode 100644 index 0000000..67b3993 --- /dev/null +++ b/.gitlab/changelog_config.yml @@ -0,0 +1,14 @@ +# See https://docs.gitlab.com/ee/user/project/changelogs.html +# For API see https://docs.gitlab.com/ee/api/repositories.html#add-changelog-data-to-a-changelog-file + +# Defines the category mapping for the markdown rendering +# trailer -> display name in markdown +categories: + added: Added + fixed: Fixed + changed: Changed + deprecated: Deprecated + removed: Removed + security: Security + performance: Performance + other: Other diff --git a/.gitlab/release-notes.md.template b/.gitlab/release-notes.md.template index 941e007..f7ce60f 100644 --- a/.gitlab/release-notes.md.template +++ b/.gitlab/release-notes.md.template @@ -1,5 +1,7 @@ Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH. +See the [CHANGELOG](CHANGELOG.md) for what changes happened in this release. + ## Usage You can use the OpenTofu CI/CD component from the CI/CD catalog using: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c6e741..fd3b1ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,3 +29,9 @@ That is, they are not bundled and it's not possible to use a component across in The OpenTofu CI/CD job and pipeline templates can be generated using `make backports`. The output is generated into the `backports` folder. Please contribute those files only upon full manual inspection to the canonical GitLab repository. + +## Releasing + +Use the `make release` command with the `VERSION` argument set to the +version of the new release, like: `make release VERSION=1.0.0`. +The version must adhere to the [Semantic Versioning](https://semver.org) format. diff --git a/Makefile b/Makefile index 5620bef..9fa6cf4 100644 --- a/Makefile +++ b/Makefile @@ -50,3 +50,17 @@ backports: @yq e 'del(.*.variables | select(length==0))' $(BACKPORTS_BASE_FILE) | diff -Bw $(BACKPORTS_BASE_FILE) - | patch $(BACKPORTS_BASE_FILE) - @echo "Generated $(BACKPORTS_BASE_FILE)" + +.PHONY: release +release: + @echo -n $(VERSION) | ./.gitlab/scripts/check-semantic-version.sh + @[ "main" = "$(shell git rev-parse --abbrev-ref HEAD)" ] || echo "Please checkout the main branch first: git checkout main" + @echo "Creating changelog ..." + @curl --method POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" 'https://gitlab.com/api/v4/projects/components%2Fopentofu/repository/changelog' --data "version=$(VERSION)&message='Add changelog for $(VERSION) [skip ci]'" + @echo "Pulling changelog ..." + @git pull + @echo "Tagging $(VERSION) ..." + @git tag $(VERSION) + @echo "Pushing tag $(VERSION) ..." + @git push origin $(VERSION) + @echo "Created tag $(VERSION), pipeline triggered, release will be available soon!" diff --git a/README.md b/README.md index d5e80df..7784f24 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,8 @@ plan: ## Releases & Versioning This project currently releases tagged commits. -An overview of releases can be found on the [Releases page](https://gitlab.com/components/opentofu/-/releases). +An overview of releases can be found on the [Releases page](https://gitlab.com/components/opentofu/-/releases) +and a Changelog can be found [here](CHANGELOG.md). Each release is accessible in the [CI/CD Catalog](https://gitlab.com/explore/catalog). -- GitLab