Skip to content

Commit

Permalink
feat: add variable for custom wiki directory separator
Browse files Browse the repository at this point in the history
Introduces a new variable to allow users to specify a directory
separator character for generating wiki titles. This supports better
representation of module directory structures in GitHub wiki titles.
The default is set to a Unicode mathematical rising diagonal (⟋),
but users can choose from other options like '∕', '⁄', and '-'.

Updated the README to document this new feature and its usage.

Fixes #80
  • Loading branch information
virgofx committed Oct 26, 2024
1 parent 56c354e commit ad0acaf
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
patch-keywords: fix,chore,docs
default-first-tag: v1.0.0
disable-wiki: false
wiki-directory-separator: ∕ # Unicode mathematical rising diagonal (U+27CB)
wiki-sidebar-changelog-max: 10
delete-legacy-tags: false # Note: We don't want to delete tags in this repository
module-change-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/**
Expand Down
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ documentation.</b></sup>
![CI](https://github.com/techpivot/terraform-module-releaser/actions/workflows/ci.yml/badge.svg?event=pull_request)
[![Lint](https://github.com/techpivot/terraform-module-releaser/actions/workflows/lint.yml/badge.svg)][3]
[![CodeQL](https://github.com/techpivot/terraform-module-releaser/actions/workflows/codeql-analysis.yml/badge.svg)][4]
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=techpivot_terraform-module-releaser&metric=alert_status)][5]

[1]: https://github.com/techpivot/terraform-module-releaser/releases/latest
[2]: https://github.com/marketplace/actions/terraform-module-releaser
[3]: https://github.com/techpivot/terraform-module-releaser/actions/workflows/lint.yml
[4]: https://github.com/techpivot/terraform-module-releaser/actions/workflows/codeql-analysis.yml
[5]: https://sonarcloud.io/summary/new_code?id=techpivot_terraform-module-releaser

Simplify the management of Terraform modules in your monorepo with this **GitHub Action**, designed to automate
module-specific versioning and releases. By streamlining the Terraform module release process, this action allows you to
Expand Down Expand Up @@ -115,6 +117,11 @@ jobs:
uses: techpivot/terraform-module-releaser@v1
```
This configuration provides an out-of-the-box solution that should work for most projects, as the defaults are
reasonably configured.
If you need to customize additional parameters, please refer to [Input Parameters](#input-parameters) section below.
## Permissions
Before executing the GitHub Actions workflow, ensure that you have the necessary permissions set for accessing pull
Expand Down Expand Up @@ -161,19 +168,20 @@ resources.
While the out-of-the-box defaults are suitable for most use cases, you can further customize the action's behavior by
configuring the following optional input parameters as needed.

| Input | Description | Default |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| `major-keywords` | Keywords in commit messages that indicate a major release | `major change,breaking change` |
| `minor-keywords` | Keywords in commit messages that indicate a minor release | `feat,feature` |
| `patch-keywords` | Keywords in commit messages that indicate a patch release | `fix,chore,docs` |
| `default-first-tag` | Specifies the default tag version | `v1.0.0` |
| `terraform-docs-version` | Specifies the terraform-docs version used to generate documentation for the wiki | `v0.19.0` |
| `delete-legacy-tags` | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | `true` |
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |
| `disable-branding` | Controls whether a small branding link to the action's repository is added to PR comments. Recommended to leave enabled to support OSS. | `false` |
| `module-change-exclude-patterns` | A comma-separated list of file patterns to exclude from triggering version changes in Terraform modules. Patterns follow glob syntax (e.g., ".gitignore,_.md") and are relative to each Terraform module directory. Files matching these patterns will not affect version changes. **WARNING**: Avoid excluding '_.tf' files, as they are essential for module detection and versioning processes. | `".gitignore,*.md,*.tftest.hcl,tests/**"` |
| `module-asset-exclude-patterns` | A comma-separated list of file patterns to exclude when bundling a Terraform module for tag/release. Patterns follow glob syntax (e.g., "tests/\*\*") and are relative to each Terraform module directory. Files matching these patterns will be excluded from the bundled output. | `".gitignore,*.md,*.tftest.hcl,tests/**"` |
| Input | Description | Default |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| <code style="white-space:nowrap;">major-keywords</code> | Keywords in commit messages that indicate a major release | `major change,breaking change` |
| `minor-keywords` | Keywords in commit messages that indicate a minor release | `feat,feature` |
| `patch-keywords` | Keywords in commit messages that indicate a patch release | `fix,chore,docs` |
| `default-first-tag` | Specifies the default tag version | `v1.0.0` |
| `terraform-docs-version` | Specifies the terraform-docs version used to generate documentation for the wiki | `v0.19.0` |
| `delete-legacy-tags` | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | `true` |
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
| `wiki-directory-separator` | Specifies a single character to replace directory separators (/) in module names when generating wiki titles. Since GitHub wiki titles don't support forward slashes, this character will be used to represent the module's directory structure in the wiki title only. Allowed options include '∕' (division slash), '⁄' (fraction slash), '-' (hyphen), and '⟋' (mathematical rising diagonal). | `⟋` |
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |
| `disable-branding` | Controls whether a small branding link to the action's repository is added to PR comments. Recommended to leave enabled to support OSS. | `false` |
| `module-change-exclude-patterns` | <h6 style="margin:0">A comma-separated list of file patterns to exclude from triggering version changes in Terraform modules. Patterns follow glob syntax (e.g., ".gitignore,_.md") and are relative to each Terraform module directory. Files matching these patterns will not affect version changes. **WARNING**: Avoid excluding '_.tf' files, as they are essential for module detection and versioning processes.</h6> | `".gitignore,*.md,*.tftest.hcl,tests/**"` |
| `module-asset-exclude-patterns` | A comma-separated list of file patterns to exclude when bundling a Terraform module for tag/release. Patterns follow glob syntax (e.g., "tests/\*\*") and are relative to each Terraform module directory. Files matching these patterns will be excluded from the bundled output. | `".gitignore,*.md,*.tftest.hcl,tests/**"` |

### Example Usage with Inputs

Expand Down Expand Up @@ -206,6 +214,7 @@ jobs:
terraform-docs-version: v0.19.0
delete-legacy-tags: true
disable-wiki: false
wiki-directory-separator: ⟋ # Unicode mathematical rising diagonal (U+27CB)
wiki-sidebar-changelog-max: 10
module-change-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/**
module-asset-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/**
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ inputs:
By default, this is set to false. Set to true to prevent wiki documentation from being generated.
required: true
default: "false"
wiki-directory-separator:
description: >
Specifies a single character to replace directory separators (/) in module names when generating wiki titles.
Since GitHub wiki titles don't support forward slashes, this character will be used to represent the module's
directory structure in the wiki title only. Allowed options include '∕' (division slash), '⁄' (fraction slash),
'-' (hyphen), and '⟋' (mathematical rising diagonal). The default is the latter.
required: true
default: "" # Unicode mathematical rising diagonal (U+27CB)
wiki-sidebar-changelog-max:
description: >
An integer that specifies how many changelog entries are displayed in the sidebar per module.
Expand Down
18 changes: 18 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { endGroup, getInput, info, startGroup } from '@actions/core';
import { ALLOWED_WIKI_SEPARATORS } from './constants';

/**
* Configuration interface used for defining key GitHub Action input configuration.
Expand Down Expand Up @@ -45,6 +46,14 @@ interface Config {
*/
disableWiki: boolean;

/**
* Specifies a single character to replace directory separators (/) in module names when generating wiki titles.
* Since GitHub wiki titles don't support forward slashes, this character will be used to represent the module's
* directory structure in the wiki title only. Allowed options include '∕' (division slash), '⁄' (fraction slash),
* '-' (hyphen), and '⟋' (mathematical rising diagonal).
*/
wikiDirectorySeparator: string;

/**
* An integer that specifies how many changelog entries are displayed in the sidebar per module.
*/
Expand Down Expand Up @@ -112,6 +121,7 @@ function initializeConfig(): Config {
terraformDocsVersion: getInput('terraform-docs-version', { required: true }),
deleteLegacyTags: getInput('delete-legacy-tags', { required: true }).toLowerCase() === 'true',
disableWiki: getInput('disable-wiki', { required: true }).toLowerCase() === 'true',
wikiDirectorySeparator: getInput('wiki-directory-separator', { required: true }),
wikiSidebarChangelogMax: Number.parseInt(getInput('wiki-sidebar-changelog-max', { required: true }), 10),
disableBranding: getInput('disable-branding', { required: true }).toLowerCase() === 'true',
githubToken: getInput('github_token', { required: true }),
Expand All @@ -126,6 +136,7 @@ function initializeConfig(): Config {
info(`Terraform Docs Version: ${configInstance.terraformDocsVersion}`);
info(`Delete Legacy Tags: ${configInstance.deleteLegacyTags}`);
info(`Disable Wiki: ${configInstance.disableWiki}`);
info(`Wiki Directory Separator: ${configInstance.wikiDirectorySeparator}`);
info(`Wiki Sidebar Changelog Max: ${configInstance.wikiSidebarChangelogMax}`);
info(`Module Change Exclude Patterns: ${configInstance.moduleChangeExcludePatterns.join(', ')}`);
info(`Module Asset Exclude Patterns: ${configInstance.moduleAssetExcludePatterns.join(', ')}`);
Expand All @@ -138,6 +149,13 @@ function initializeConfig(): Config {
throw new Error('Asset exclude patterns cannot contain "*.tf" as these files are required');
}

// Validate wiki directory separator
if (!ALLOWED_WIKI_SEPARATORS.includes(configInstance.wikiDirectorySeparator)) {
throw new Error(
`Invalid wiki directory separator '${configInstance.wikiDirectorySeparator}'. Must be one of: '${ALLOWED_WIKI_SEPARATORS.join("', '")}'`,
);
}

endGroup();

return configInstance;
Expand Down
7 changes: 7 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ export const BRANDING_COMMENT =

export const BRANDING_WIKI =
'<h4 align="center">Powered by <img src="https://raw.githubusercontent.com/techpivot/terraform-module-releaser/refs/heads/main/assets/github-mark-12x14.png" height="14" width="12" align="top" /> <a href="https://github.com/techpivot/terraform-module-releaser">techpivot/terraform-module-releaser</a></h4>';

export const ALLOWED_WIKI_SEPARATORS = [
'⟋', // Mathematical rising diagonal (U+27CB)
'∕', // Division slash (U+2215)
'⁄', // Fraction slash (U+2044)
'-', // Hyphen
];
Loading

0 comments on commit ad0acaf

Please sign in to comment.