Skip to content

Commit

Permalink
docs: add git-chglog for changelog generation (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylesomers authored Jun 4, 2024
1 parent 43f6c53 commit 040f64b
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 25 deletions.
56 changes: 56 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}

{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
28 changes: 28 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/aws-games/cloud-game-development-toolkit
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "Version to build and publish docs (i.e. 0.1.0-alpha.1, latest)"
description: "Version to build and publish docs (i.e. v0.1.0-alpha.1, v1.0.0)"
required: true
type: string
alias:
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
echo "VERSION is: ${{ inputs.version }}"
echo "ALIAS is: ${{ inputs.alias }}"
- name: Build docs
run: make docs-build VERSION=$RELEASE_VERSION
run: make docs-build VERSION="$VERSION"
- name: Deploy Docs
run: make docs-deploy VERSION="$RELEASE_VERSION" ALIAS="$ALIAS"
run: make docs-deploy VERSION="$VERSION" ALIAS="$ALIAS"

33 changes: 11 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
.PHONY: help docs-build docs-local-docker docs-deploy

.DEFAULT_GOAL := help

###########################################################
# ENVIRONMENT VARIABLES
###########################################################
ifeq ($(GITHUB_ACTIONS),true)
GIT_USER_NAME := github-actions[bot]
GIT_USER_EMAIL := "41898282+github-actions[bot]@users.noreply.github.com"
Expand All @@ -13,10 +8,6 @@ else
GIT_USER_EMAIL := $(shell git config user.email)
endif

###########################################################
# COLOR CONFIGURATION
# Check if the terminal supports color, define color codes
###########################################################
COLOR_SUPPORT := $(shell tput colors 2>/dev/null)
# Define color codes if the terminal supports color
ifdef COLOR_SUPPORT
Expand All @@ -28,35 +19,33 @@ ifdef COLOR_SUPPORT
endif
endif

###########################################################
# docs-build
###########################################################

.PHONY: docs-build
docs-build: ## Build the docs using docker. Example: `make docs-build VERSION=1.0.0`
@if [ -z "${VERSION}" ]; then echo -e "${RED}VERSION is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@echo -e "Docs version is: ${GREEN}$(VERSION)${RESET}"
docker build -f ./docs/Dockerfile -t docs:$(VERSION) . --build-arg GIT_USER_NAME="$(GIT_USER_NAME)" --build-arg GIT_USER_EMAIL="$(GIT_USER_EMAIL)" --build-arg GITHUB_ACTIONS=$(GITHUB_ACTIONS) --no-cache
docker build -f ./docs/Dockerfile -t docs:$(VERSION) . \
--build-arg GIT_USER_NAME="$(GIT_USER_NAME)" \
--build-arg GIT_USER_EMAIL="$(GIT_USER_EMAIL)" \
--build-arg GITHUB_ACTIONS=$(GITHUB_ACTIONS) \
--no-cache

###########################################################
# docs-deploy
###########################################################
.PHONY: docs-deploy
docs-deploy: ## Deploy the docs using 'mike'. Example: `make docs-deploy VERSION=1.0.0 ALIAS=latest`
@if [ -z "${VERSION}" ]; then echo -e "${RED}VERSION is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@if [ -z "${ALIAS}" ]; then echo -e "${RED}ALIAS is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@echo -e "Docs version is: ${GREEN}$(VERSION)${RESET}"
docker run -t docs:$(VERSION) mike deploy --push --update-aliases $(VERSION) ${ALIAS}

###########################################################
# docs-local-docker
###########################################################

.PHONY: docs-local
docs-local-docker: ## Build and run the docs locally using docker and 'serve'. Example: `make docs-local-docker VERSION=1.0.0`
@if [ -z "${VERSION}" ]; then echo -e "${RED}VERSION is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@echo -e "Docs version is: ${GREEN}$(VERSION)${RESET}"
docker build -f ./docs/Dockerfile -t docs:$(VERSION) . --build-arg GIT_USER_NAME="$(GIT_USER_NAME)" --build-arg GIT_USER_EMAIL="$(GIT_USER_EMAIL)" --build-arg GITHUB_ACTIONS=$(GITHUB_ACTIONS) --no-cache
docker run -t docs:$(VERSION) mike deploy --push --update-aliases $(VERSION) latest

###########################################################
# help
###########################################################
.PHONY: help
help: ## Display this help
@echo -e "Usage: make [TARGET]\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${CYAN}%-30s${RESET} %s\n", $$1, $$2}'

0 comments on commit 040f64b

Please sign in to comment.