mirror of
https://github.com/orhun/git-cliff-action.git
synced 2026-03-22 07:25:43 +08:00
feat: add version input variable (#27)
* feat: add version input variable Signed-off-by: Ludovic Ortega <ludovic.ortega@adminafk.fr> * chore(docs): readme typo Signed-off-by: Ludovic Ortega <ludovic.ortega@adminafk.fr> * fix: use bash script file instead of raw script * fix: variable interpolation * fix: GITHUB_TOKEN bash variable interpolation * fix: output version description * fix: VERSION variable interpolation * fix: add back "lastest" in version description * fix: add suggested changes Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com> * refactor: polish implementation * chore: bump version --------- Signed-off-by: Ludovic Ortega <ludovic.ortega@adminafk.fr> Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
This commit is contained in:
13
.github/dependabot.yml
vendored
13
.github/dependabot.yml
vendored
@@ -13,16 +13,3 @@ updates:
|
|||||||
patch:
|
patch:
|
||||||
update-types:
|
update-types:
|
||||||
- "patch"
|
- "patch"
|
||||||
# Maintain dependencies for docker
|
|
||||||
- package-ecosystem: docker
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
open-pull-requests-limit: 10
|
|
||||||
groups:
|
|
||||||
minor:
|
|
||||||
update-types:
|
|
||||||
- "minor"
|
|
||||||
patch:
|
|
||||||
update-types:
|
|
||||||
- "patch"
|
|
||||||
18
Dockerfile
18
Dockerfile
@@ -1,18 +0,0 @@
|
|||||||
FROM orhunp/git-cliff:2.5.0@sha256:1decc44f731f4f95777429ead823a0a6df8159c877c8a59ac79c34d45f899105
|
|
||||||
|
|
||||||
LABEL maintainer="orhun <orhunparmaksiz@gmail.com>"
|
|
||||||
LABEL repository="https://github.com/orhun/git-cliff-action"
|
|
||||||
LABEL homepage="https://github.com/orhun/git-cliff"
|
|
||||||
|
|
||||||
LABEL com.github.actions.name="Changelog Generator"
|
|
||||||
LABEL com.github.actions.description="Generate changelog based on your Git history"
|
|
||||||
LABEL com.github.actions.icon="triangle"
|
|
||||||
LABEL com.github.actions.color="green"
|
|
||||||
|
|
||||||
COPY README.md /
|
|
||||||
COPY LICENSE /
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
@@ -6,6 +6,7 @@ This action generates a changelog based on your Git history using [git-cliff](ht
|
|||||||
|
|
||||||
### Input variables
|
### Input variables
|
||||||
|
|
||||||
|
- `version`: `git-cliff` version to use (Default: `"latest"`)
|
||||||
- `config`: Path of the configuration file. (Default: `"cliff.toml"`)
|
- `config`: Path of the configuration file. (Default: `"cliff.toml"`)
|
||||||
- `args`: [Arguments](https://github.com/orhun/git-cliff#usage) to pass to git-cliff. (Default: `"-v"`)
|
- `args`: [Arguments](https://github.com/orhun/git-cliff#usage) to pass to git-cliff. (Default: `"-v"`)
|
||||||
|
|
||||||
@@ -49,9 +50,10 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Generate a changelog
|
- name: Generate a changelog
|
||||||
uses: orhun/git-cliff-action@v3
|
uses: orhun/git-cliff-action@v4
|
||||||
id: git-cliff
|
id: git-cliff
|
||||||
with:
|
with:
|
||||||
|
version: latest
|
||||||
config: cliff.toml
|
config: cliff.toml
|
||||||
args: --verbose
|
args: --verbose
|
||||||
env:
|
env:
|
||||||
@@ -81,7 +83,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Generate a changelog
|
- name: Generate a changelog
|
||||||
uses: orhun/git-cliff-action@v3
|
uses: orhun/git-cliff-action@v4
|
||||||
id: git-cliff
|
id: git-cliff
|
||||||
with:
|
with:
|
||||||
config: cliff.toml
|
config: cliff.toml
|
||||||
@@ -130,7 +132,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Generate a changelog
|
- name: Generate a changelog
|
||||||
uses: orhun/git-cliff-action@v3
|
uses: orhun/git-cliff-action@v4
|
||||||
with:
|
with:
|
||||||
config: cliff.toml
|
config: cliff.toml
|
||||||
args: --verbose
|
args: --verbose
|
||||||
|
|||||||
28
action.yml
28
action.yml
@@ -1,6 +1,10 @@
|
|||||||
name: "git-cliff - Changelog Generator"
|
name: "git-cliff - Changelog Generator"
|
||||||
description: "Generate changelog based on your Git history"
|
description: "Generate changelog based on your Git history"
|
||||||
inputs:
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "git-cliff version"
|
||||||
|
required: false
|
||||||
|
default: "latest"
|
||||||
config:
|
config:
|
||||||
description: "config file location"
|
description: "config file location"
|
||||||
required: false
|
required: false
|
||||||
@@ -12,16 +16,30 @@ inputs:
|
|||||||
outputs:
|
outputs:
|
||||||
changelog:
|
changelog:
|
||||||
description: "output file"
|
description: "output file"
|
||||||
|
value: ${{ steps.run-git-cliff.outputs.changelog }}
|
||||||
content:
|
content:
|
||||||
description: "content of the changelog"
|
description: "content of the changelog"
|
||||||
|
value: ${{ steps.run-git-cliff.outputs.content }}
|
||||||
version:
|
version:
|
||||||
description: "version of the latest release"
|
description: "version of the latest release"
|
||||||
|
value: ${{ steps.run-git-cliff.outputs.version }}
|
||||||
runs:
|
runs:
|
||||||
using: "docker"
|
using: "composite"
|
||||||
image: "Dockerfile"
|
steps:
|
||||||
args:
|
- name: Download git-cliff
|
||||||
- --config=${{ inputs.config }}
|
shell: bash
|
||||||
- ${{ inputs.args }}
|
run: ${{ github.action_path }}/install.sh
|
||||||
|
env:
|
||||||
|
RUNNER_OS: ${{ runner.os }}
|
||||||
|
RUNNER_ARCH: ${{ runner.arch }}
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Run git-cliff
|
||||||
|
id: run-git-cliff
|
||||||
|
shell: bash
|
||||||
|
run: ${{ github.action_path }}/run.sh --config=${{ inputs.config }} ${{ inputs.args }}
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: "triangle"
|
icon: "triangle"
|
||||||
color: "green"
|
color: "green"
|
||||||
|
|||||||
41
install.sh
Executable file
41
install.sh
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -uxo pipefail
|
||||||
|
|
||||||
|
case "${RUNNER_OS}" in
|
||||||
|
macOS) OS=apple-darwin ;;
|
||||||
|
Windows) OS=pc-windows-msvc ;;
|
||||||
|
*) OS=unknown-linux-gnu ;;
|
||||||
|
esac
|
||||||
|
case "${RUNNER_ARCH}" in
|
||||||
|
ARM64) ARCH=aarch64 ;;
|
||||||
|
ARM) ARCH=pc-windows-msvc ;;
|
||||||
|
X86) ARCH=i686 ;;
|
||||||
|
*) ARCH=x86_64 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest'
|
||||||
|
if [[ "${VERSION}" != 'latest' ]]; then
|
||||||
|
RELEASE_URL="https://api.github.com/repos/orhun/git-cliff/releases/tags/${VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Although releases endpoint is available without authentication, the current github.token is still passed
|
||||||
|
# in order to increase the limit of 60 requests per hour per IP address to a higher value that's also counted
|
||||||
|
# per GitHub account.
|
||||||
|
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
|
||||||
|
RELEASE_INFO="$(curl --silent --show-error --fail \
|
||||||
|
--header "authorization: Bearer ${GITHUB_TOKEN}" \
|
||||||
|
--header 'Cache-Control: no-cache, must-revalidate' \
|
||||||
|
"${RELEASE_URL}")"
|
||||||
|
TAG_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".tag_name")"
|
||||||
|
TARGET="git-cliff-${TAG_NAME:1}-${ARCH}-${OS}.tar.gz"
|
||||||
|
LOCATION="$(echo "${RELEASE_INFO}" \
|
||||||
|
| jq --raw-output ".assets[].browser_download_url" \
|
||||||
|
| grep "${TARGET}$")"
|
||||||
|
|
||||||
|
# Skip downloading release if downloaded already, e.g. when the action is used multiple times.
|
||||||
|
if [[ ! -e "$TARGET" ]]; then
|
||||||
|
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION"
|
||||||
|
tar -xf "$TARGET"
|
||||||
|
mv git-cliff-${TAG_NAME:1}/git-cliff .
|
||||||
|
fi
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash -l
|
#!/bin/bash
|
||||||
|
|
||||||
set -uxo pipefail
|
set -uxo pipefail
|
||||||
|
|
||||||
# Avoid file expansion when passing parameters like with '*'
|
# Avoid file expansion when passing parameters like with '*'
|
||||||
@@ -16,12 +17,12 @@ mkdir -p "$(dirname $OUTPUT)"
|
|||||||
args=$(echo "$@" | xargs)
|
args=$(echo "$@" | xargs)
|
||||||
|
|
||||||
# Execute git-cliff
|
# Execute git-cliff
|
||||||
GIT_CLIFF_OUTPUT="$OUTPUT" git-cliff $args
|
GIT_CLIFF_OUTPUT="$OUTPUT" ./git-cliff $args
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
# Retrieve context
|
# Retrieve context
|
||||||
CONTEXT="$(mktemp)"
|
CONTEXT="$(mktemp)"
|
||||||
GIT_CLIFF_OUTPUT="$CONTEXT" git-cliff $args --context
|
GIT_CLIFF_OUTPUT="$CONTEXT" ./git-cliff $args --context
|
||||||
|
|
||||||
# Output to console
|
# Output to console
|
||||||
cat "$OUTPUT"
|
cat "$OUTPUT"
|
||||||
Reference in New Issue
Block a user