Skip to content

Commit b3d6bd5

Browse files
release: v1.0.0 (#2)
1 parent 8d5c0d7 commit b3d6bd5

8 files changed

Lines changed: 412 additions & 2 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Prepare Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
call-prepare:
14+
uses: leoweyr/github-release-workflow/.github/workflows/reusable-prepare-release.yml@develop
15+
secrets:
16+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
call-publish:
12+
uses: leoweyr/github-release-workflow/.github/workflows/reusable-publish-release.yml@develop
13+
secrets:
14+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
node-verions:
7+
description: 'Node.js version to use.'
8+
required: false
9+
type: string
10+
default: '20'
11+
commit-user-name:
12+
description: 'Git user name for commit'
13+
required: false
14+
type: string
15+
default: 'github-actions[bot]'
16+
commit-user-email:
17+
description: 'Git user email for commit.'
18+
required: false
19+
type: string
20+
default: 'github-actions[bot]@users.noreply.github.com'
21+
secrets:
22+
ACCESS_TOKEN:
23+
required: true
24+
description: 'GitHub Token for authentication.'
25+
26+
jobs:
27+
prepare-release:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Checkout Config
36+
uses: actions/checkout@v4
37+
with:
38+
repository: 'leoweyr/github-release-workflow'
39+
path: .change-log-config
40+
sparse-checkout: src/cliff.toml
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: ${{ inputs.node-verions }}
46+
47+
- name: Set Environment Variables
48+
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
49+
50+
- name: Create Release Branch
51+
run: |
52+
git config --global user.name "${{ inputs.commit-user-name }}"
53+
git config --global user.email "${{ inputs.commit-user-email }}"
54+
git checkout -b release/${{ env.TAG_NAME }}
55+
56+
- name: Generate Changelog Content for PR Body
57+
env:
58+
GITHUB_REPO: ${{ github.repository }}
59+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
60+
run: |
61+
npx git-cliff --config .change-log-config/src/cliff.toml --verbose --latest --strip all > pr_body_raw.md
62+
63+
- name: Save PR Body to File
64+
run: |
65+
cat pr_body_raw.md | tail -n +2 > pr_body_cleaned.md
66+
67+
- name: Update CHANGELOG.md File
68+
env:
69+
GITHUB_REPO: ${{ github.repository }}
70+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
71+
run: |
72+
if [ -f "CHANGELOG.md" ]; then
73+
# File exists: Prepend new changes (git-cliff intelligently handles headers).
74+
npx git-cliff --config .change-log-config/src/cliff.toml --verbose --latest --prepend CHANGELOG.md
75+
else
76+
# File missing: Create new with full history and header.
77+
npx git-cliff --config .change-log-config/src/cliff.toml --verbose --output CHANGELOG.md
78+
fi
79+
80+
- name: Commit and Push
81+
run: |
82+
git add CHANGELOG.md
83+
git commit -m "release: ${{ env.TAG_NAME }}"
84+
git push origin release/${{ env.TAG_NAME }}
85+
86+
- name: Create Pull Request
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
89+
run: |
90+
gh pr create \
91+
--title "release: ${{ env.TAG_NAME }}" \
92+
--body-file pr_body_cleaned.md \
93+
--base master \
94+
--head release/${{ env.TAG_NAME }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
ACCESS_TOKEN:
7+
required: true
8+
9+
jobs:
10+
publish-release:
11+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'release:')
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Extract Tag Name
21+
id: extract_tag
22+
run: |
23+
TITLE="${{ github.event.pull_request.title }}"
24+
TAG_NAME=$(echo "$TITLE" | sed 's/release: //')
25+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
26+
VERSION_TITLE=${TAG_NAME#v}
27+
echo "VERSION_TITLE=$VERSION_TITLE" >> $GITHUB_ENV
28+
29+
- name: Create Release Body File
30+
env:
31+
PR_BODY: ${{ github.event.pull_request.body }}
32+
run: echo "$PR_BODY" > release_body.md
33+
34+
- name: Create GitHub Release
35+
env:
36+
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
37+
run: |
38+
gh release create ${{ env.TAG_NAME }} \
39+
--title "${{ env.VERSION_TITLE }}" \
40+
--notes-file release_body.md \
41+
--verify-tag

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
# [1.0.0] (2026-03-20)
6+
### Bug Fixes
7+
8+
* move reusable workflows back to .github/workflows directory ([0b0676e](https://github.com/leoweyr/github-release-workflow/commit/0b0676e413f95b39d33c79d64ffc0259a3783206)) [@leoweyr](https://github.com/leoweyr)
9+
* add missing reusable release workflows ([456d0c9](https://github.com/leoweyr/github-release-workflow/commit/456d0c9348aad3d41e1d4b61aca8f7cd50194261)) [@leoweyr](https://github.com/leoweyr)
10+
* rename reserved GITHUB_TOKEN secret in reusable workflows ([8d2afaa](https://github.com/leoweyr/github-release-workflow/commit/8d2afaa30e97c3c735bfe39b1d822879d834d4de)) [@leoweyr](https://github.com/leoweyr)
11+
* correct git-cliff config path to prevent fallback to default ([7aef3e8](https://github.com/leoweyr/github-release-workflow/commit/7aef3e84c53bacded51601db6dcab4b9e765634e)) [@leoweyr](https://github.com/leoweyr)
12+
13+
14+
### Features
15+
16+
* add prepare release workflow ([4bec90f](https://github.com/leoweyr/github-release-workflow/commit/4bec90f7d44eda66efce0e48bec8079a5c98430c)) [@leoweyr](https://github.com/leoweyr)
17+
* add publish release workflow ([20daca8](https://github.com/leoweyr/github-release-workflow/commit/20daca810acd33ee6071d7e5668fca95e203e797)) [@leoweyr](https://github.com/leoweyr)
18+
* add user-facing workflows ([047bf99](https://github.com/leoweyr/github-release-workflow/commit/047bf996a00bb3fae423b17cb3d31a9392184b65)) [@leoweyr](https://github.com/leoweyr)
19+
* add change log config ([4b667a0](https://github.com/leoweyr/github-release-workflow/commit/4b667a058ca7d14aa9960b7834262f5d7ee43a15)) [@leoweyr](https://github.com/leoweyr)
20+
21+
22+
### Documentation
23+
24+
* update readme with usage instructions ([7e15921](https://github.com/leoweyr/github-release-workflow/commit/7e15921622d59b01fa1f571a707ca4ffad7d5a94)) [@leoweyr](https://github.com/leoweyr)
25+
* **readme:** add banner ([e81214e](https://github.com/leoweyr/github-release-workflow/commit/e81214ea480b1bbd1c63ea78cb7c4c32af085513)) [@leoweyr](https://github.com/leoweyr)
26+
27+
28+
### Miscellaneous Tasks
29+
30+
* move reusable workflows to src ([e48851c](https://github.com/leoweyr/github-release-workflow/commit/e48851ca6f5f92f075fae900cfc1332b7a507a20)) [@leoweyr](https://github.com/leoweyr)
31+
* add icon ([04e730f](https://github.com/leoweyr/github-release-workflow/commit/04e730fc0a68c554c8b40f65ec949cdc4763ee73)) [@leoweyr](https://github.com/leoweyr)
32+
* correct eye perspective in icon ([2ad0a73](https://github.com/leoweyr/github-release-workflow/commit/2ad0a7312fc8b75b7945679a71845ca68efbe43b)) [@leoweyr](https://github.com/leoweyr)
33+
34+
35+
36+
<!-- Generated by git-cliff. -->

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1-
# GitHub Release Workflow
1+
![github-release-workflow](https://socialify.git.ci/leoweyr/github-release-workflow/image?description=1&font=KoHo&forks=1&issues=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2Fleoweyr%2Fgithub-release-workflow%2Frefs%2Fheads%2Fdevelop%2Fassets%2Ficon.svg&name=1&owner=1&pattern=Formal+Invitation&pulls=1&stargazers=1&theme=Light)
22

3-
Streamline your software delivery with a production-ready engineering workflow. Automated semantic versioning, changelog generation (via git-cliff), and GitHub release publishing.
3+
> [!IMPORTANT]
4+
> To ensure changelogs are generated correctly, all git commit messages must follow the **[Conventional Commits](https://www.conventionalcommits.org/)** specification.
5+
>
6+
> Also, you must go to your repository **Settings > Actions > General > Workflow permissions** and enable **"Allow GitHub Actions to create and approve pull requests"**, otherwise the automated release process will fail.
7+
8+
## 🚀 Instant Magic for Your Repository!!!
9+
10+
Add professional release automation to your personal project with a single step:
11+
12+
**Copy the `prepare-release.yml` and `publish-release.yml` files from `.github/workflows` into your project's `.github/workflows` directory.**
13+
14+
✨ That's it! Your repository is now enchanted.
15+
16+
## ⚙ How It Works
17+
18+
This workflow streamlines your release process into a few simple steps:
19+
20+
1. **Tag Your Release**: On your development branch (separate from `master` or `main`), create a git tag with a `v` prefix (e.g., `v1.0.0`).
21+
```bash
22+
git tag v1.0.0
23+
```
24+
25+
2. **Push the Tag**: Push the tag to GitHub.
26+
```bash
27+
git push origin v1.0.0
28+
```
29+
30+
3. **Automated Magic**: GitHub Actions will automatically:
31+
* Generate a changelog based on your conventional commits.
32+
* Create a specific release branch.
33+
* Open a Pull Request to your default branch (e.g., `master`).
34+
35+
4. **Review and Merge**: Review the Pull Request created by the bot.
36+
* **Do not modify the Pull Request title or body**, as they are used for the release metadata.
37+
* Merge the Pull Request.
38+
* The workflow will automatically create a GitHub Release for you.

assets/icon.svg

Lines changed: 89 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)