Skip to content

Commit

Permalink
image switch (#1)
Browse files Browse the repository at this point in the history
* switch to apline with minimal required deps
* add release cfg rc file to docker, set/check env vars
* wire up input options, show output, update readme
* add no-args option for full changelog, update readme

Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold authored Feb 27, 2021
1 parent 5bc834c commit 2ea09c7
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 55 deletions.
196 changes: 196 additions & 0 deletions .gitchangelog-release.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
##
## Format
##
## ACTION: [AUDIENCE:] COMMIT_MSG [!TAG ...]
##
## Description
##
## ACTION is one of 'chg', 'fix', 'new'
##
## Is WHAT the change is about.
##
## 'chg' is for refactor, small improvement, cosmetic changes...
## 'fix' is for bug fixes
## 'new' is for new features, big improvement
##
## AUDIENCE is optional and one of 'dev', 'usr', 'pkg', 'test', 'doc'
##
## Is WHO is concerned by the change.
##
## 'dev' is for developpers (API changes, refactors...)
## 'usr' is for final users (UI changes)
## 'pkg' is for packagers (packaging changes)
## 'test' is for testers (test only related changes)
## 'doc' is for doc guys (doc only changes)
##
## COMMIT_MSG is ... well ... the commit message itself.
##
## TAGs are additionnal adjective as 'refactor' 'minor' 'cosmetic'
##
## They are preceded with a '!' or a '@' (prefer the former, as the
## latter is wrongly interpreted in github.) Commonly used tags are:
##
## 'refactor' is obviously for refactoring code only
## 'minor' is for a very meaningless change (a typo, adding a comment)
## 'cosmetic' is for cosmetic driven change (re-indentation, 80-col...)
## 'wip' is for partial functionality but complete subfunctionality.
##
## Example:
##
## new: usr: support of bazaar implemented
## chg: re-indentend some lines !cosmetic
## new: dev: updated code to be compatible with last version of killer lib.
## fix: pkg: updated year of licence coverage.
## new: test: added a bunch of test around user usability of feature X.
## fix: typo in spelling my name in comment. !minor
##
## Please note that multi-line commit message are supported, and only the
## first line will be considered as the "summary" of the commit message. So
## tags, and other rules only applies to the summary. The body of the commit
## message will be displayed in the changelog without reformatting.


##
## ``ignore_regexps`` is a line of regexps
##
## Any commit having its full commit message matching any regexp listed here
## will be ignored and won't be reported in the changelog.
##
ignore_regexps = [
r'@minor', r'!minor',
r'@cosmetic', r'!cosmetic',
r'@refactor', r'!refactor',
r'@wip', r'!wip',
r'^([cC]hg|[fF]ix|[nN]ew|[fF]eat)\s*:\s*[p|P]kg:',
r'^([cC]hg|[fF]ix|[nN]ew|[Ff]eat)\s*:\s*[d|D]ev:',
r'^(.{3,3}\s*:)?\s*[fF]irst commit.?\s*$',
r'^\d+\.\d+\.\d+$',
]


## ``section_regexps`` is a list of 2-tuples associating a string label and a
## list of regexp
##
## Commit messages will be classified in sections thanks to this. Section
## titles are the label, and a commit is classified under this section if any
## of the regexps associated is matching.
##
## Please note that ``section_regexps`` will only classify commits and won't
## make any changes to the contents. So you'll probably want to go check
## ``subject_process`` (or ``body_process``) to do some changes to the subject,
## whenever you are tweaking this variable.
##
section_regexps = [
('Features', [
r'^([nN]ew|[fF]eat)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Changes', [
r'^[cC]hg\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
('Fixes', [
r'^[fF]ix\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
]),
]


## ``body_process`` is a callable
##
## This callable will be given the original body and result will
## be used in the changelog.
##
## Available constructs are:
##
## - any python callable that take one txt argument and return txt argument.
##
## - ReSub(pattern, replacement): will apply regexp substitution.
##
## - Indent(chars=" "): will indent the text with the prefix
## Please remember that template engines gets also to modify the text and
## will usually indent themselves the text if needed.
##
## - Wrap(regexp=r"\n\n"): re-wrap text in separate paragraph to fill 80-Columns
##
## - noop: do nothing
##
## - ucfirst: ensure the first letter is uppercase.
## (usually used in the ``subject_process`` pipeline)
##
## - final_dot: ensure text finishes with a dot
## (usually used in the ``subject_process`` pipeline)
##
## - strip: remove any spaces before or after the content of the string
##
## Additionally, you can `pipe` the provided filters, for instance:
#body_process = Wrap(regexp=r'\n(?=\w+\s*:)') | Indent(chars=" ")
#body_process = Wrap(regexp=r'\n(?=\w+\s*:)')
#body_process = noop
#body_process = ReSub(r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$', r'') | strip
body_process = lambda text: ""


## ``subject_process`` is a callable
##
## This callable will be given the original subject and result will
## be used in the changelog.
##
## Available constructs are those listed in ``body_process`` doc.
subject_process = (strip |
ReSub(r'^([cC]hg|[fF]ix|[nN]ew|[fF]eat)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') |
ucfirst | final_dot)


## ``tag_filter_regexp`` is a regexp
##
## Tags that will be used for the changelog must match this regexp.
##
tag_filter_regexp = r'^v?[0-9]+\.[0-9]+(\.[0-9]+)?$'


## ``unreleased_version_label`` is a string
##
## This label will be used as the changelog Title of the last set of changes
## between last valid tag and HEAD if any.
unreleased_version_label = "(unreleased)"
#unreleased_version_label = lambda: swrap(
# ["git", "describe", "--tags"],
#shell=False)

## ``output_engine`` is a callable
##
## This will change the output format of the generated changelog file
##
## Available choices are:
##
## - rest_py
##
## Legacy pure python engine, outputs ReSTructured text.
## This is the default.
##
## - mustache(<template_name>)
##
## Template name could be any of the available templates in
## ``templates/mustache/*.tpl``.
## Requires python package ``pystache``.
## Examples:
## - mustache("markdown")
## - mustache("restructuredtext")
##
## - makotemplate(<template_name>)
##
## Template name could be any of the available templates in
## ``templates/mako/*.tpl``.
## Requires python package ``mako``.
## Examples:
## - makotemplate("restructuredtext")
##
#output_engine = rest_py
#output_engine = mustache("restructuredtext")
output_engine = mustache("markdown")
#output_engine = makotemplate("restructuredtext")


## ``include_merge`` is a boolean
##
## This option tells git-log whether to include merge commits in the log.
## The default is to include them.
include_merge = True
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ jobs:
uses: ./ # Uses an action in the root directory
with:
github_token: ${{ secrets.GITHUB_TOKEN}}

- name: Display changes file
run: cat CHANGES.md
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM alpine

LABEL "maintainer"="Stephen Arnold <[email protected]>" \
"repository"="https://github.com/sarnold/gitchangelog-action" \
Expand All @@ -8,16 +8,16 @@ LABEL "maintainer"="Stephen Arnold <[email protected]>" \
"com.github.actions.icon"="check-circle" \
"com.github.actions.color"="package"

ENV DEBIAN_FRONTEND noninteractive
# Set PYTHONUNBUFFERED so we don't get interleaved output
ENV PYTHONUNBUFFERED 1
RUN apk --no-cache add \
python3 \
python3-dev \
bash \
git \
py3-pip

RUN apt-get update && \
apt-get install --no-install-suggests --no-install-recommends -y git && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /tmp/* && \
python3 -m pip install https://github.com/sarnold/gitchangelog/archive/3.0.5.tar.gz
RUN pip3 install https://github.com/sarnold/gitchangelog/archive/3.0.5.tar.gz

ADD ./.gitchangelog-release.rc /.gitchangelog-release.rc

ADD ./genchangelog.sh /genchangelog.sh

Expand Down
45 changes: 24 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ A Github Action for gitchangelog


What is gitchangelog?
=============

gitchangelog_
=====================

gitchangelog_ creates a changelog from git log history using multiple
template engines and a config file. Output can be either `reStructuredText`_
or `MarkDown`_, with the latter format as default for this action (mainly
for generating GitHub release pages).

By default this action will ues the ``gitchangelog.rc.github.release``
config file installed by the gitchangelog package.



Expand All @@ -43,18 +49,14 @@ Default configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: gitchangelog action step
uses: sarnold/gitchangelog-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN}}

- name: upload metrics report
uses: actions/upload-artifact@v2
with:
name: metrics
path: ./metrics


Advanced configuration
----------------------
Expand All @@ -65,7 +67,7 @@ Advanced configuration
on: [push]

jobs:
check:
release:
name: gitchangelog-action
runs-on: ubuntu-latest
steps:
Expand All @@ -78,7 +80,7 @@ Advanced configuration
with:
github_token: ${{ secrets.GITHUB_TOKEN}}
output_file: CHANGELOG.rst
extra_sort: True
config_file: .gitchangelog-custom.rc


Input Options
Expand All @@ -89,12 +91,13 @@ Input Options
you can see what it *would* do before you actually enable it.


:github_token: GITHUB_TOKEN secret (automatically provided by Github,
you don't need to set this up)
:commit_changelog: Whether to commit the report files (default: false)
:output_file: Filename for changelog (default is CHANGES.md)
:extra_sort: Additionally sort the list of found tags (default is False)
:target_branch: Branch that the action will target (default is current branch)
:github_token: GITHUB_TOKEN secret (automatically provided by Github)
:config_file: Path to gitchangelog.rc (default: Markdown release cfg)
:output_file: Filename for changelog (default: CHANGES.md)
:extra_sort: Additionally sort the list of found tags (default: False)
:no_args: Pass no ref args to gitchangelog (always generate full changelog)
:commit_changelog: Whether to commit the changelog file (default: false)
:target_branch: Branch that the action will target (default: current branch)


Input Constraints
Expand All @@ -114,15 +117,15 @@ Operating System Support
------------------------

This action runs in a Docker container and requires the Ubuntu_ CI runner.
In your workflow job configuration, you'll need to set the ``runs-on``
In your workflow job configuration, you should set the ``runs-on``
property to ``ubuntu-latest``::

jobs:
metrics:
release:
runs-on: ubuntu-latest

The ``gitchangelog`` tool itself is built and tested in github CI using Linux,
Macos, and Windows, so you can always generate output on your local
The ``gitchangelog`` tool itself is built and tested in github CI using
Linux, Macos, and Windows, so you can always generate output on your local
machine as needed.


Expand Down
18 changes: 14 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ inputs:
description: "GITHUB_TOKEN secret < automatically provided by Github , you don't need to set up >"
required: true

config_file:
description: "Path to gitchangelog.rc (default uses Markdown release cfg)"
default: ""
required: false

output_file:
description: "Filename for changelog (default is CHANGES.md)"
default: "CHANGES.md"
required: false

commit_changelog:
description: "Whether to commit the changelog file"
extra_sort:
description: "Whether to sort the list of tags (fix ordering issues)"
default: ""
required: false

extra_sort:
description: "Whether to sort the list of found tags (fix ordering issues)"
no_args:
description: "Pass no ref args to gitchangelog (always generate full changelog)"
default: ""
required: false

commit_changelog:
description: "Whether to commit the changelog file"
default: ""
required: false

Expand Down
Loading

0 comments on commit 2ea09c7

Please sign in to comment.