Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate and optimize release note creation #4522

Draft
wants to merge 12 commits into
base: stable
Choose a base branch
from
9 changes: 8 additions & 1 deletion .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ doc_files: &doc_files
- package.json
- package-lock.json

release_files: &release_files
- "changelog/*.md"
- CHANGELOG.md
- "docs/docs/relese_notes/infrahub/*.mdx"

helm_files: &helm_files
- "helm/**"

Expand All @@ -46,7 +51,6 @@ yaml_all: &yaml_all
markdown_all: &markdown_all
- "**/*.{md,mdx}"


backend_all:
- *backend_files
- *ci_config
Expand All @@ -58,6 +62,9 @@ documentation_all:
- *doc_files
- *markdown_all

release_all:
- *release_files

helm_all:
- *helm_files

Expand Down
33 changes: 30 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
outputs:
backend: ${{ steps.changes.outputs.backend_all }}
documentation: ${{ steps.changes.outputs.documentation_all }}
release: ${{ steps.changes.outputs.release_all }}
frontend: ${{ steps.changes.outputs.frontend_all }}
helm: ${{ steps.changes.outputs.helm_all }}
e2e: ${{ steps.changes.outputs.e2e_all }}
Expand Down Expand Up @@ -130,7 +131,9 @@ jobs:
run: "ruff format --check --diff ."

markdown-lint:
if: needs.files-changed.outputs.documentation == 'true'
if: |
needs.files-changed.outputs.documentation == 'true' ||
needs.files-changed.outputs.release == 'true'
needs: ["files-changed"]
runs-on: "ubuntu-latest"
timeout-minutes: 5
Expand All @@ -145,7 +148,6 @@ jobs:
config: .markdownlint.yaml
globs: |
**/*.{md,mdx}
!changelog/*.md

action-lint:
if: needs.files-changed.outputs.github_workflows == 'true'
Expand Down Expand Up @@ -528,7 +530,32 @@ jobs:
env:
VALE_VERSION: ${{ env.VALE_VERSION }}
- name: "Validate documentation style"
run: ./vale $(find . -type f \( -name "*.mdx" -o -name "*.md" \) -not -path "./docs/node_modules/*")
run: ./vale $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) -not -path "./docs/node_modules/*")

validate-release-notes-style:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true
# The official GitHub Action for Vale doesn't work, installing manually instead:
# https://github.com/errata-ai/vale-action/issues/103
- name: Download Vale
run: |
curl -sL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" -o vale.tar.gz
tar -xzf vale.tar.gz
env:
VALE_VERSION: ${{ env.VALE_VERSION }}
- name: "Validate documentation style"
run: ./vale $(find ./changelog ./docs/docs/release-notes/infrahub -type f \( -name '*.mdx' -o -name '*.md' \)) CHANGELOG.md

# ------------------------------------------ E2E Tests ------------------------------------------
E2E-testing-playwright:
Expand Down
3 changes: 3 additions & 0 deletions .vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ BasedOnStyles = Infrahub
;(import.*?\n) to ignore import statement in .mdx
;(```.*?```\n) to ignore code block in .mdx
BlockIgnores = (?s) *((import.*?\n)|(```.*?```\n))

[*]
BasedOnStyles = Infrahub
1 change: 1 addition & 0 deletions .vale/styles/spelling-exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ subnet
template_path
toml
Towncrier
towncrier
uncheck
uniqueness_constraints
validator
Expand Down
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Infrahub Changelog
# Infrahub changelog

This is the changelog for Infrahub.
All notable changes to this project will be documented in this file.

Issue tracking is located in [Github](https://github.com/opsmill/infrahub/issues).
Issue tracking is located in [GitHub](https://github.com/opsmill/infrahub/issues).

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Expand Down Expand Up @@ -34,7 +34,7 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
- Fix performance issue for GraphQL queries that only count nodes. ([#4454](https://github.com/opsmill/infrahub/issues/4454))
- Fix ability to construct HFID for upsert mutations where a number attribute is used. ([#4460](https://github.com/opsmill/infrahub/issues/4460))

## [0.16.1](https://github.com/opsmill/infrahub/tree/v0.16.1) - 2024-09-24
## [Infrahub - v0.16.1](https://github.com/opsmill/infrahub/tree/infrahub-v0.16.1) - 2024-09-24

The largest change in this version is the movement of the Infrahub SDK into a
[separate repository](https://github.com/opsmill/infrahub-sdk-python) and package.
Expand Down Expand Up @@ -99,7 +99,7 @@ git submodule update --init
- Added cancel button in repository form ([#4402](https://github.com/opsmill/infrahub/issues/4402))
- Fixes the tasks pagination in the proposed changes tab ([#4434](https://github.com/opsmill/infrahub/issues/4434))

## [0.16.0](https://github.com/opsmill/infrahub/tree/v0.16.0) - 2024-09-11
## [Infrahub - v0.16.0](https://github.com/opsmill/infrahub/tree/infrahub-v0.16.0) - 2024-09-11

### Removed

Expand Down Expand Up @@ -148,7 +148,7 @@ git submodule update --init
- Do not allow '/' character in repository name to avoid sync failure. ([#4120](https://github.com/opsmill/infrahub/issues/4120))
- Can't close a comment thread on an Artifact. ([#4189](https://github.com/opsmill/infrahub/issues/4189))

## [0.15.3](https://github.com/opsmill/infrahub/tree/v0.15.3) - 2024-08-13
## [Infrahub - v0.15.3](https://github.com/opsmill/infrahub/tree/infrahub-v0.15.3) - 2024-08-13

### Added

Expand Down
1 change: 1 addition & 0 deletions changelog/+changelog_edits.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Editing old `CHANGELOG.md` entries to use uniform formatting from new Towncrier template.
1 change: 1 addition & 0 deletions changelog/+towncrier_template.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added custom Towncrier template to remove extra space after new Changelog entries.
1 change: 1 addition & 0 deletions changelog/4519.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adding `invoke` tasks to assist with release process.
30 changes: 30 additions & 0 deletions changelog/docs_release_notes.mdx.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Release {{ version }}
---
<table>
<tbody>
<tr>
<th>Release Number</th>
<td>{{ version }}</td>
</tr>
<tr>
<th>Release Date</th>
<td>{{ today }}</td>
</tr>
<tr>
<th>Release Codename</th>
<td>{{ codename }}</td>
</tr>
<tr>
<th>Tag</th>
<td>[infrahub-v{{ version }}](https://github.com/opsmill/infrahub/releases/tag/infrahub-v{{ version }})</td>
</tr>
</tbody>
</table>

# Release 0.16.2

We are thrilled to announce the latest release of Infrahub, version *{{ version }}*!

This release focuses largely on bug fixes and is driven by our Beta Test users,
and as always we greatly appreciate their feedback and time!
19 changes: 19 additions & 0 deletions changelog/github_release_notes.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Main Changes

{{ changelog_contents }}

## Migration Guide

### Rebuild the demo environment

It's mandatory to completely rebuild your demo environment with the following commands.

```
invoke demo.destroy demo.build demo.start
invoke demo.load-infra-schema
invoke demo.load-infra-data
```

> All data will be lost, please make sure to backup everything you need before running this command.

The repository https://github.com/opsmill/infrahub-demo-edge has also been updated, it's recommend to pull the latest changes into your fork.
54 changes: 54 additions & 0 deletions changelog/towncrier.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% if render_title %}
{% if versiondata.name %}
# {{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
{% else %}
# {{ versiondata.version }} ({{ versiondata.date }})
{% endif %}
{% endif %}
{% for section, _ in sections.items() %}
{% if section %}

## {{section}}
{% endif %}

{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section] %}
### {{ definitions[category]['name'] }}

{% for text, values in sections[section][category].items() %}
- {{ text }}
{%- if values %}
{% if "\n - " in text or '\n * ' in text %}


(
{%- else %}
{% if text %} ({% endif %}
{%- endif -%}
{%- for issue in values %}
{{ issue.split(": ", 1)[0] }}{% if not loop.last %}, {% endif %}
{%- endfor %}
{% if text %}){% endif %}

{% else %}

{% endif %}
{% endfor %}

{% if issues_by_category[section][category] and "]: " in issues_by_category[section][category][0] %}
{% for issue in issues_by_category[section][category] %}
{{ issue }}
{% endfor %}

{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes.

{% else %}
{% endif %}
{% endfor %}
{% else %}
No significant changes.

{% endif %}
{% endfor +%}
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,10 @@ directory = "changelog"
filename = "CHANGELOG.md"
start_string = "<!-- towncrier release notes start -->\n"
underlines = ["", "", ""]
title_format = "## [{version}](https://github.com/opsmill/infrahub/tree/v{version}) - {project_date}"
title_format = "## [Infrahub - v{version}](https://github.com/opsmill/infrahub/tree/infrahub-v{version}) - {project_date}"
issue_format = "[#{issue}](https://github.com/opsmill/infrahub/issues/{issue})"
orphan_prefix = "+"
template = "changelog/towncrier.md.template"

[[tool.towncrier.type]]
directory = "security"
Expand Down
3 changes: 2 additions & 1 deletion tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from invoke import Collection, Context, task

from . import backend, demo, dev, docs, main, performance, schema, sdk, sync
from . import backend, demo, dev, docs, main, performance, release, schema, sdk, sync

ns = Collection()
ns.add_collection(sdk)
Expand All @@ -14,6 +14,7 @@
ns.add_collection(main)
ns.add_collection(schema)
ns.add_collection(sync)
ns.add_collection(release)


@task
Expand Down
2 changes: 1 addition & 1 deletion tasks/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def vale(context: Context):
print("Warning, Vale is not installed")
return

exec_cmd = "vale $(find . -type f \\( -name '*.mdx' -o -name '*.md' \\) -not -path './docs/node_modules/*')"
exec_cmd = "vale $(find ./docs -type f \\( -name '*.mdx' -o -name '*.md' \\) -not -path './docs/node_modules/*')"
print(" - [docs] Lint docs with vale")
with context.cd(ESCAPED_REPO_PATH):
context.run(exec_cmd)
Expand Down
76 changes: 76 additions & 0 deletions tasks/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""Release related Invoke Tasks."""

from invoke import Context, task

from .utils import ESCAPED_REPO_PATH, check_if_command_available


@task
def markdownlint(context: Context):
has_markdownlint = check_if_command_available(context=context, command_name="markdownlint-cli2")

if not has_markdownlint:
print("Warning, markdownlint-cli2 is not installed")
return
exec_cmd = "markdownlint-cli2 'changelog/*.md' '!changelog/towncrier_template.md' 'CHANGELOG.md' 'docs/docs/release-notes/infrahub/*.{md,mdx}'"
print(" - [release] Lint release files with markdownlint-cli2")
with context.cd(ESCAPED_REPO_PATH):
context.run(exec_cmd)


@task
def vale(context: Context):
"""Run vale to validate the release notes."""
has_vale = check_if_command_available(context=context, command_name="vale")

if not has_vale:
print("Warning, Vale is not installed")
return

exec_cmd = "vale $(find ./changelog ./docs/docs/release-notes/infrahub -type f \\( -name '*.mdx' -o -name '*.md' \\)) CHANGELOG.md"
print(" - [release] Lint release files with vale")
with context.cd(ESCAPED_REPO_PATH):
context.run(exec_cmd)


@task
def draft(context: Context):
"""Run `towncrier build --draft` to validate that Towncrier can read the Newsfragments."""
has_towncrier = check_if_command_available(context=context, command_name="towncrier")

if not has_towncrier:
print("Warning, Towncrier is not installed")
return

exec_cmd = "towncrier build --draft"
print(" - [release] Verify Towncrier render possible")
with context.cd(ESCAPED_REPO_PATH):
context.run(exec_cmd)


@task
def lint(context: Context):
"""This will run all linters."""
markdownlint(context)
vale(context)
draft(context)


@task
def build_changelog(context: Context):
has_towncrier = check_if_command_available(context=context, command_name="towncrier")

if not has_towncrier:
print("Warning, Towncrier is not installed")
return

exec_cmd = "towncrier build --draft 2> /dev/null"
with context.cd(ESCAPED_REPO_PATH):
changelog_contents = context.run(exec_cmd, hide="stdout").stdout
# print(changelog_contents)


@task
def ship(context: Context):
"""This will generate the Release Notes and prepare to ship the release."""
lint(context)
Loading