|
| 1 | +<!-- enh(CI): Automatic Release Workflow --> |
| 2 | + |
| 3 | +# Automatic Release Workflow |
| 4 | + |
| 5 | +This PR introduces a `release` workflow that runs on the first day of every month, check for changes on `master`, and, if so, creates a new release after approval. |
| 6 | + |
| 7 | +- Closes #57 |
| 8 | + |
| 9 | +## Tag Selection |
| 10 | + |
| 11 | +The `verify` job selects a tag name with format `%Y.%m.%d` (e.g. `2025.08.01`), which always ends in `01` since it runs on the first day of each month. If the tag is newer then the previous one and there are changes in `master`, then the workflow generates a change summary and continues to the `release` job, which request a review and awaits for approval. |
| 12 | + |
| 13 | +*The examples below use format `%Y.%m.%d-%H` for faster (test) release cycles, but everything else is the same.* |
| 14 | + |
| 15 | +### Summary |
| 16 | + |
| 17 | +The summary is generated with `git diff --histogram --stat $latest_tag..HEAD` and `git log --no-merges $latest_tag..HEAD`, so merge commits are not displayed. |
| 18 | + |
| 19 | +<details><summary><b>Release Summary</b></summary> |
| 20 | + |
| 21 | +````md |
| 22 | +## Proposing new release `2025.07.14-05` |
| 23 | +### Changes since [`2025.07.13-23`](https://github.com/marmitar/nano-syntax-highlighting/releases/tag/2025.07.13-23) |
| 24 | +```log |
| 25 | + git.nanorc | 17 ++++++++--------- |
| 26 | + readme.md | 7 +++---- |
| 27 | + 2 files changed, 11 insertions(+), 13 deletions(-) |
| 28 | +``` |
| 29 | +### Git log |
| 30 | +```log |
| 31 | +commit ce788aa4e727ea09e542c8b91e59574645dc75a0 |
| 32 | +Author: Tiago de Paula < [email protected]> |
| 33 | +Date: Sun Jul 13 23:32:45 2025 -0300 |
| 34 | + |
| 35 | + enh(gitcommit): improve colors for kitty+fish combo |
| 36 | + |
| 37 | +commit 22592a37ddc9639b206f4c6e5859d4421348b4dd |
| 38 | +Author: Tiago de Paula < [email protected]> |
| 39 | +Date: Sun Jul 13 23:24:01 2025 -0300 |
| 40 | + |
| 41 | + chore(readme): add release badge |
| 42 | + |
| 43 | +commit dd9e3ca50d430f6ffc1b8c4d79af76e37b52f754 |
| 44 | +Author: Tiago de Paula < [email protected]> |
| 45 | +Date: Sun Jul 13 23:17:13 2025 -0300 |
| 46 | + |
| 47 | + chore(readme): restore package manager information |
| 48 | +``` |
| 49 | +```` |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +</details> |
| 56 | + |
| 57 | +- Examples: [#30](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16254545342), [#35](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16258745959), [#37](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16260703509) |
| 58 | + |
| 59 | +### Checks |
| 60 | + |
| 61 | +Each tag is checked to be newer using lexicographical order, which works for `%Y.%m.%d`. Just be aware of any additional text after the date. For example, `2025.07.01-2` is considered newer than `2025.07.01-10`. |
| 62 | + |
| 63 | +After that, `master` is checked for code changes with `git diff --quiet $latest_tag`, and the release is skipped if no change is reported. |
| 64 | + |
| 65 | +In both cases, skipping the relase is not considered a failure. The workflow just finishes early and no notification is sent anywhere. |
| 66 | + |
| 67 | +<details><summary><b>Outdated Release</b></summary> |
| 68 | + |
| 69 | +````md |
| 70 | +## Skipping release `2025.07.13-23` |
| 71 | +Latest tag [`2025.07.13-23`](https://github.com/marmitar/nano-syntax-highlighting/releases/tag/2025.07.13-23) already covers this date. |
| 72 | +```` |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +</details> |
| 79 | + |
| 80 | +<details><summary><b>Release with No Changes</b></summary> |
| 81 | + |
| 82 | +````md |
| 83 | +## Skipping release `2025.07.14-02` |
| 84 | +No changes since [`2025.07.13-23`](https://github.com/marmitar/nano-syntax-highlighting/releases/tag/2025.07.13-23). |
| 85 | +```` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +</details> |
| 92 | + |
| 93 | +- Examples: [#31](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16256097841), [#32](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16256116191), [#33](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16256260221), [#36](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16259810098) |
| 94 | + |
| 95 | +### Manual Release |
| 96 | + |
| 97 | +The job can also be triggered manually on [Actions page](https://github.com/galenguyer/nano-syntax-highlighting/actions/workflows/release.yml), with an optional `release_tag` different from `%Y.%m.%d`. You can also change the [deploy `environment`](#github-environment) for this manual run. |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +<details><summary><b>Full Page</b></summary> |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +</details> |
| 106 | + |
| 107 | +## Workflow Review |
| 108 | + |
| 109 | +Once `verify` completes with a non-empty `release_tag`, the workflow request reviews from defined members before starting the `release` job. |
| 110 | + |
| 111 | +<details><summary>Release Verified, Awaiting Review</summary> |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +</details> |
| 116 | + |
| 117 | +<details><summary>Review Notification Sent to Email</summary> |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +</details> |
| 122 | + |
| 123 | +<details><summary>Review Page</summary> |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +</details> |
| 128 | + |
| 129 | +<details><summary>Release Approved</summary> |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | +</details> |
| 134 | + |
| 135 | +<details><summary>Release Created</summary> |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +</details> |
| 140 | + |
| 141 | +### GitHub Environment |
| 142 | + |
| 143 | +> [!IMPORTANT] |
| 144 | +> This step requires manual configuration in the repository Settings. |
| 145 | +
|
| 146 | +The review system uses [deploy environments on Github](https://docs.github.com/en/actions/how-tos/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment). The workflow doesn't actually use any information from the environment, but if the environment is configured with "Required reviewers", then it won't run by itself. Here I used `release` as the name of the environment. |
| 147 | + |
| 148 | +<details><summary><b>Environment Settings</b></summary> |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | +</details> |
| 153 | + |
| 154 | +### Job Concurrency |
| 155 | + |
| 156 | +To avoid multiple competing releases, I've set up a `concurrency` `group` that disallows concurrent runs of the `release.yml` workflow. If a new workflow starts while the last one is still running, then the new one has priority and the other is cancelled. In practice, this should only happen if a release is left unapproved for more than a month. |
| 157 | + |
| 158 | +<details><summary><b>Unapproved Release</b></summary> |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +</details> |
| 163 | + |
| 164 | +- Example: [#24](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16251594856), [#25](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16252200601), [#26](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16252593840), [#27](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16253110094), [#28](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16253570186), [#29](https://github.com/marmitar/nano-syntax-highlighting/actions/runs/16254058395) |
| 165 | + |
| 166 | +## Release Creation |
| 167 | + |
| 168 | +Once the `release` job is approved and runs, it creates a tag with the name `release_tag` provided by `verify`, pointing to the last commit on `master`. It also creates a [GitHub release](https://github.com/galenguyer/nano-syntax-highlighting/releases) with [automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes), which can be configured in a `.github/release.yml` file. By default, the generated notes list all pull requests since the last release (which might be a lot for the first one here, you can create a first release to avoid this). |
| 169 | + |
| 170 | +<details><summary><b>Changelog Example</b></summary> |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | +</details> |
| 177 | + |
| 178 | +- Examples: [2025.07.13-23](https://github.com/marmitar/nano-syntax-highlighting/releases/tag/2025.07.13-23), [2025.07.14-05](https://github.com/marmitar/nano-syntax-highlighting/releases/tag/2025.07.14-05), [2025.07.14-07](https://github.com/marmitar/nano-syntax-highlighting/releases/tag/2025.07.14-07) |
| 179 | + |
| 180 | +## Implementation Notes |
| 181 | + |
| 182 | +There's currently an issue (actions/checkout#1467) with `fetch_tags` on Git 2.48 (`ubunut-latest`), which requires explicit fetching of the git history using `fetch-depth` and `ref`. I used the last 100 commits for `fetch-depth`, which should be more than enough for a month. The workaround implemented here can be removed after the fix actions/checkout#2200 lands. |
0 commit comments