Skip to content

Commit 8983eb2

Browse files
committed
feat(ci): add bump action
1 parent fc8bbcd commit 8983eb2

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

.cz.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ commitizen:
66
update_changelog_on_bump: true
77
version: 0.0.1
88
version_scheme: semver2
9+
annotated_tag: true

.github/workflows/bump.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
jobs:
7+
bump:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
actions: write
12+
steps:
13+
- uses: actions/checkout@v5
14+
with:
15+
fetch-depth: 0
16+
fetch-tags: true
17+
- name: Set up git config
18+
run: |
19+
git config --global user.name "github-actions[bot]"
20+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
21+
- uses: actions/setup-cz@main
22+
- uses: pndurette/gh-actions-auto-docs@v1
23+
with:
24+
git_push: false
25+
- id: bump-version
26+
run: |
27+
cz bump --yes
28+
current_version="v$(cz version -p --current)"
29+
major_version="v$(cz version -p --major)"
30+
echo "current_version=$current_version" >> $GITHUB_OUTPUT
31+
echo "major_version=$major_version" >> $GITHUB_OUTPUT
32+
- name: Update major tag
33+
env:
34+
CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }}
35+
MAJOR_VERSION: ${{ steps.bump-version.outputs.major_version }}
36+
run: |
37+
# Push new commit + new tag
38+
git push --follow-tags
39+
40+
# Move major tag to the latest commit
41+
git tag -fa "${MAJOR_VERSION}" -m "release ${CURRENT_VERSION}"
42+
43+
# Force push new major tag
44+
git push origin "${MAJOR_VERSION}" -f
45+
- name: Build changelog
46+
env:
47+
CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }}
48+
run: |
49+
cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md
50+
- name: Release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
body_path: ".changelog.md"
54+
tag_name: ${{ steps.bump-version.outputs.current_version }}
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
11
# setup-cz
2-
Github action to configure cz
2+
3+
> Github action to configure cz
4+
5+
## Usage
6+
7+
```yaml
8+
jobs:
9+
bump:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
actions: write
14+
steps:
15+
- uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
18+
fetch-tags: true
19+
- uses: actions/setup-cz@main
20+
- name: Set up git config
21+
run: |
22+
git config --global user.name "github-actions[bot]"
23+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
24+
- run: |
25+
cz version -p
26+
cz bump --yes --annotated-tag
27+
git push --follow-tags
28+
```
29+
30+
<!--doc_begin-->
31+
<!--doc_end-->

0 commit comments

Comments
 (0)