Skip to content

Commit 4bae443

Browse files
committed
bump to 1.2.0
2 parents effc6b5 + 722084b commit 4bae443

File tree

5 files changed

+53
-16
lines changed

5 files changed

+53
-16
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ on:
55

66
jobs:
77
release:
8+
if: github.repository == 'lumynou5/github-release-action'
89
runs-on: ubuntu-latest
910
steps:
1011
- name: Checkout
1112
uses: actions/checkout@v3
12-
13+
1314
- name: Release
14-
uses: lumynou5/github-release-action@main
15+
uses: lumynou5/github-release-action@v1
1516
with:
1617
token: ${{github.token}}

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [1.2.0] - 2024-01-16
5+
### Added
6+
- Minor tag.
7+
### Changed
8+
- Major tag of major version 0.
9+
### Fixed
10+
- Templates using multiple parameters work as expected now.
11+
412
## [1.1.1] - 2023-05-05
513
### Fixed
614
- Accidently used tuple for tag name.
715

8-
## [1.1.0] - 2023-05-05
16+
## [1.1.0] - 2023-05-05 [YANKED]
917
### Added
1018
- Outputs the names of the Git tags of the release and the major version; i.e., the filled templates are outputed.
1119
- Input `major-tag-template` can be empty for no major tag now.
@@ -18,6 +26,7 @@ All notable changes to this project will be documented in this file.
1826
### Added
1927
- First release.
2028

29+
[1.2.2]: https://github.com/lumynou5/github-release-action/releases/tag/v1.2.0
2130
[1.1.1]: https://github.com/lumynou5/github-release-action/releases/tag/v1.1.1
2231
[1.1.0]: https://github.com/lumynou5/github-release-action/releases/tag/v1.1.0
2332
[1.0.1]: https://github.com/lumynou5/github-release-action/releases/tag/v1.0.1

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@ jobs:
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v3
18-
18+
1919
- name: Release
20-
# Use the latest version.
21-
uses: lumynou5/github-release-action@main
20+
uses: lumynou5/github-release-action@v1
2221
with:
2322
token: ${{github.token}}
2423
```
2524
2625
In this example workflow, it'll create a release whenever push to `main` branch.
27-
The version will be set according to the changelog following [Keep a Changelog](https://keepachangelog.com/)
28-
and [Semantic Versioning](https://semver.org/).
26+
The version and the release note will be captured from the changelog following
27+
[Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
28+
And a Git tag will be created for the major revision, see [Inputs](#Inputs) for more information.
2929

30-
Specifically, a release is created and the tag of the corresponding major version is moved onto that version.
31-
If there isn't a tag of the major version, it'll be created.
30+
This is useful to automatically publish releases on pushing to the stable branch when using Git flow, etc.
3231

3332
## Inputs
3433
- `token` (required)
@@ -38,13 +37,19 @@ If there isn't a tag of the major version, it'll be created.
3837
- `tag-template`
3938
The template of the Git tag. Default: `v{version}`.
4039
- `major-tag-template`
41-
The template of the Git tag of the major version. Default: `v{major}`. Empty for no major tag.
40+
The template of the Git tag of the major version. Doesn't perform if the major version is 0.
41+
Default: `v{major}`. Empty for no major tag.
42+
- `minor-tag-template`
43+
The template of the Git tag of the minor version. Default: `v{maojr}.{minor}`. Empty for no minor tag.
4244
- `name-template`
4345
The template of the GitHub release. Default: `v{version}`.
4446
- `is-draft`
4547
If the GitHub release is a draft. Default: `false`.
4648

47-
The following list shows the arguments can be used in the template.
49+
The following list shows the parameters that can be used in templates.
50+
To use parameters, add a parameter name wrapping with braces to your template,
51+
and it will be replaced with data from your changelog;
52+
i.e. `{parameter-name}` will be replaced with the corresponding value.
4853
- `version`
4954
The version.
5055
- `major`
@@ -61,12 +66,18 @@ The following list shows the arguments can be used in the template.
6166
The release date.
6267

6368
## Outputs
64-
The outputs include all the arguments of templates and the following items in addition.
69+
The outputs include all the parameters of templates and the following items in addition.
6570
- `tag`
6671
The name of the Git tag.
6772
- `major-tag`
6873
The name of the Git tag of the major version.
74+
- `minor-tag`
75+
The name of the Git tag of the minor version.
6976
- `html-url`
7077
The URL to the page of the GitHub release.
7178
- `upload-url`
7279
The URL to upload assets for the GitHub release.
80+
81+
## License
82+
The source code is distributed under the MIT license.
83+
See [LICENSE.md](LICENSE.md) for further information.

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ inputs:
2020
description: The template of the Git tag of the major version.
2121
required: false
2222
default: v{major}
23+
minor-tag-template:
24+
description: The template of the Git tag of the major version.
25+
required: false
26+
default: v{major}.{minor}
2327
name-template:
2428
description: The template of the GitHub release.
2529
required: false
2630
default: v{version}
2731
is-draft:
2832
description: If the GitHub release is a draft.
2933
required: false
30-
default: false
34+
default: 'false'
3135
outputs:
3236
version:
3337
description: The version.

main.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def fillTemplate(template, data):
1313
i = 0
1414
while i < len(template):
1515
if template[i] == '{':
16-
end = template.find('}')
16+
end = template.find('}', i)
1717
if end == -1:
1818
result += template[i:]
1919
break
@@ -55,7 +55,7 @@ def fillTemplate(template, data):
5555
env['GITHUB_SHA'])
5656

5757
# Move major tag.
58-
if env['INPUT_MAJOR-TAG-TEMPLATE'] != '':
58+
if env['INPUT_MAJOR-TAG-TEMPLATE'] != '' and data['major'] != 0:
5959
major_tag = fillTemplate(env['INPUT_MAJOR-TAG-TEMPLATE'], data)
6060
major = repo.get_git_ref(f'tags/{major_tag}')
6161
if major.ref is not None:
@@ -65,9 +65,21 @@ def fillTemplate(template, data):
6565
else:
6666
major_tag = ''
6767

68+
# Move minor tag.
69+
if env['INPUT_MINOR-TAG-TEMPLATE'] != '':
70+
minor_tag = fillTemplate(env['INPUT_MINOR-TAG-TEMPLATE'], data)
71+
minor = repo.get_git_ref(f'tags/{minor_tag}')
72+
if minor.ref is not None:
73+
minor.edit(env['GITHUB_SHA'])
74+
else:
75+
repo.create_git_ref(f'refs/tags/{minor_tag}', env['GITHUB_SHA'])
76+
else:
77+
minor_tag = ''
78+
6879
# Output.
6980
data['tag'] = tag
7081
data['major-tag'] = major_tag
82+
data['minor-tag'] = minor_tag
7183
data['html-url'] = release.html_url
7284
data['upload-url'] = release.upload_url
7385
with open(env['GITHUB_OUTPUT'], 'a') as out:

0 commit comments

Comments
 (0)