-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
108 lines (104 loc) · 3.23 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Commit Changelog Generator
description: Generates a changelog from commits since the previous release.
branding:
icon: list
color: purple
inputs:
config:
description: Path to the config file
default: ${{ github.workspace }}/.changelog-generator.yaml
path:
description: Path to the local git repository
default: .
output:
description: Generated changelog path
token:
description: GitHub token
default: ${{ github.token }}
install-only:
description: Installs changelog-generator without running it
default: "false"
outputs:
changelog:
description: The generated changelog markdown
value: ${{ steps.changelog.outputs.changelog }}
runs:
using: composite
steps:
- id: install
name: Install Changelog Generator
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPO: gabe565/changelog-generator
GH_ACTION_REF: ${{ github.action_ref }}
run: |
set -euo pipefail
case "${{ runner.os }}" in
Linux)
OS=linux
FILENAME=changelog-generator
;;
macOS)
OS=darwin
FILENAME=changelog-generator
;;
Windows)
OS=windows
FILENAME=changelog-generator.exe
;;
esac
case "$GH_ACTION_REF" in
v*.*.*)
RELEASE="$(gh release view --json=name,assets "$GH_ACTION_REF")" ;;
v*)
GH_ACTION_REF="$(gh release list --json=name | jq -r --arg major "$GH_ACTION_REF" '[.[].name | select(startswith($major))] | first')"
RELEASE="$(gh release view --json=name,assets "$GH_ACTION_REF")" ;;
*)
RELEASE="$(gh release view --json=name,assets)" ;;
esac
if [[ -z "$RELEASE" ]]; then
RELEASE="$(gh release view --json=name,assets)"
fi
VERSION="$(jq -r '.name' <<<"$RELEASE")"
echo "version=$VERSION" >>$GITHUB_OUTPUT
echo "Installing changelog generator $VERSION..."
DEST="$RUNNER_TEMP/changelog-generator"
ASSET="$(jq -r --arg OS "$OS" \
'.assets[].name | select(ascii_downcase | test($OS + "_(amd64|x86_64).(tar.gz|zip)$"))' \
<<<"$RELEASE" \
)"
echo "Downloading $ASSET"
mkdir -p "$DEST"
cd "$DEST"
case "$ASSET" in
*.tar.gz)
gh release download "$VERSION" --pattern="$ASSET" --output=- | tar -xzf - "$FILENAME" ;;
*.zip)
gh release download "$VERSION" --pattern="$ASSET"
unzip -o "$ASSET" "$FILENAME"
rm "$ASSET"
;;
*)
echo Invalid file type; exit 1;;
esac
echo "$DEST" >>$GITHUB_PATH
- id: changelog
if: inputs.install-only == 'false'
shell: bash
env:
repo: ${{ inputs.path }}
output: ${{ inputs.output }}
run: |
changelog="$(changelog-generator --repo="$repo")"
echo '::group::Generated Changelog'
echo "$changelog"
echo '::endgroup::'
{
echo 'changelog<<EOF'
echo "$changelog"
echo EOF
} >> $GITHUB_OUTPUT
if [[ -n "$output" ]]; then
echo "$changelog" > "$output"
fi