Skip to content

Commit

Permalink
bump to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lumynou5 committed Jan 16, 2024
2 parents effc6b5 + 722084b commit 4bae443
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ on:

jobs:
release:
if: github.repository == 'lumynou5/github-release-action'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Release
uses: lumynou5/github-release-action@main
uses: lumynou5/github-release-action@v1
with:
token: ${{github.token}}
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.2.0] - 2024-01-16
### Added
- Minor tag.
### Changed
- Major tag of major version 0.
### Fixed
- Templates using multiple parameters work as expected now.

## [1.1.1] - 2023-05-05
### Fixed
- Accidently used tuple for tag name.

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

[1.2.2]: https://github.com/lumynou5/github-release-action/releases/tag/v1.2.0
[1.1.1]: https://github.com/lumynou5/github-release-action/releases/tag/v1.1.1
[1.1.0]: https://github.com/lumynou5/github-release-action/releases/tag/v1.1.0
[1.0.1]: https://github.com/lumynou5/github-release-action/releases/tag/v1.0.1
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Release
# Use the latest version.
uses: lumynou5/github-release-action@main
uses: lumynou5/github-release-action@v1
with:
token: ${{github.token}}
```
In this example workflow, it'll create a release whenever push to `main` branch.
The version will be set according to the changelog following [Keep a Changelog](https://keepachangelog.com/)
and [Semantic Versioning](https://semver.org/).
The version and the release note will be captured from the changelog following
[Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
And a Git tag will be created for the major revision, see [Inputs](#Inputs) for more information.

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

## Inputs
- `token` (required)
Expand All @@ -38,13 +37,19 @@ If there isn't a tag of the major version, it'll be created.
- `tag-template`
The template of the Git tag. Default: `v{version}`.
- `major-tag-template`
The template of the Git tag of the major version. Default: `v{major}`. Empty for no major tag.
The template of the Git tag of the major version. Doesn't perform if the major version is 0.
Default: `v{major}`. Empty for no major tag.
- `minor-tag-template`
The template of the Git tag of the minor version. Default: `v{maojr}.{minor}`. Empty for no minor tag.
- `name-template`
The template of the GitHub release. Default: `v{version}`.
- `is-draft`
If the GitHub release is a draft. Default: `false`.

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

## Outputs
The outputs include all the arguments of templates and the following items in addition.
The outputs include all the parameters of templates and the following items in addition.
- `tag`
The name of the Git tag.
- `major-tag`
The name of the Git tag of the major version.
- `minor-tag`
The name of the Git tag of the minor version.
- `html-url`
The URL to the page of the GitHub release.
- `upload-url`
The URL to upload assets for the GitHub release.

## License
The source code is distributed under the MIT license.
See [LICENSE.md](LICENSE.md) for further information.
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ inputs:
description: The template of the Git tag of the major version.
required: false
default: v{major}
minor-tag-template:
description: The template of the Git tag of the major version.
required: false
default: v{major}.{minor}
name-template:
description: The template of the GitHub release.
required: false
default: v{version}
is-draft:
description: If the GitHub release is a draft.
required: false
default: false
default: 'false'
outputs:
version:
description: The version.
Expand Down
16 changes: 14 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def fillTemplate(template, data):
i = 0
while i < len(template):
if template[i] == '{':
end = template.find('}')
end = template.find('}', i)
if end == -1:
result += template[i:]
break
Expand Down Expand Up @@ -55,7 +55,7 @@ def fillTemplate(template, data):
env['GITHUB_SHA'])

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

# Move minor tag.
if env['INPUT_MINOR-TAG-TEMPLATE'] != '':
minor_tag = fillTemplate(env['INPUT_MINOR-TAG-TEMPLATE'], data)
minor = repo.get_git_ref(f'tags/{minor_tag}')
if minor.ref is not None:
minor.edit(env['GITHUB_SHA'])
else:
repo.create_git_ref(f'refs/tags/{minor_tag}', env['GITHUB_SHA'])
else:
minor_tag = ''

# Output.
data['tag'] = tag
data['major-tag'] = major_tag
data['minor-tag'] = minor_tag
data['html-url'] = release.html_url
data['upload-url'] = release.upload_url
with open(env['GITHUB_OUTPUT'], 'a') as out:
Expand Down

0 comments on commit 4bae443

Please sign in to comment.