-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
140 lines (104 loc) · 4.19 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
# yamllint disable rule:line-length
name: Changelog
description: Renders changelog
inputs:
long_changelog_export_filename:
description: 'Path for long changelog to export into'
type: string
default: ".changelog_long.md"
short_changelog_export_filename:
description: 'Path for short changelog to export into'
type: string
default: ".changelog_short.md"
long_changelog_format:
description: 'Format for long changelog'
type: string
default: "%w(1000)* %cd %an <%ae>%n%w(1000,0,2)- %s%n"
short_changelog_format:
description: 'Format for short changelog'
type: string
default: "%w(200,0,2)- %s (%an <%ae>)"
changelog_ref_start:
description: 'Ref to start changelog from (default: last tag)'
type: string
required: false
changelog_ref_end:
description: 'Ref to start changelog from (default: HEAD)'
type: string
required: false
changelog_header:
description: 'Header before the actual changelog (default: # Changelog)'
type: string
default: "# Changelog\n"
print_out_changelogs:
description: 'Whether to print out rendered changelogs or not'
type: boolean
default: false
outputs:
long_changelog_export_filename:
description: "Path to rendered long changelog"
value: ${{ steps.generate_changelog.outputs.long_changelog_export_filename }}
short_changelog_export_filename:
description: "Path to rendered short changelog"
value: ${{ steps.generate_changelog.outputs.short_changelog_export_filename }}
runs:
using: "composite"
steps:
- name: Generate changelog
id: generate_changelog
shell: bash
run: |
echo "::debug::inputs.changelog_ref_start: '${{ inputs.changelog_ref_start }}'"
echo "::debug::inputs.changelog_ref_end: '${{ inputs.changelog_ref_end }}'"
if [[ -z "${{ inputs.changelog_ref_start }}" ]]; then
described=$(git describe --tags || git rev-list --max-parents=0 HEAD)
described_parts=( ${described//-/ } )
changelog_ref_start="${described_parts[0]}"
else
changelog_ref_start=${{ inputs.changelog_ref_start }}
fi
echo "::debug::changelog_ref_start: '${changelog_ref_start}'"
if [[ -z "${{ inputs.changelog_ref_end }}" ]]; then
changelog_ref_end="HEAD"
else
changelog_ref_end=${{ inputs.changelog_ref_end }}
fi
echo "::debug::changelog_ref_end: '${changelog_ref_end}'"
long_changelog_export_filename="${{ inputs.long_changelog_export_filename }}"
short_changelog_export_filename="${{ inputs.short_changelog_export_filename }}"
echo "::debug::long_changelog_export_filename: '${long_changelog_export_filename}'"
echo "::debug::short_changelog_export_filename: '${short_changelog_export_filename}'"
if [[ -n "${{ inputs.changelog_header }}" ]]; then
cat << EOF >> "${long_changelog_export_filename}"
${{ inputs.changelog_header }}
EOF
cat << EOF >> "${short_changelog_export_filename}"
${{ inputs.changelog_header }}
EOF
fi
git log \
--pretty=oneline \
--format='${{ inputs.long_changelog_format }}' \
--date="format:%a %b %d %Y" \
"${changelog_ref_start}".."${changelog_ref_end}" >> "${long_changelog_export_filename}"
git log \
--pretty=oneline \
--format='${{ inputs.short_changelog_format }}' \
--date="format:%a %b %d %Y" \
"${changelog_ref_start}".."${changelog_ref_end}" | sort >> "${short_changelog_export_filename}"
echo "::set-output name=long_changelog_export_filename::${long_changelog_export_filename}"
echo "::set-output name=short_changelog_export_filename::${short_changelog_export_filename}"
- name: Display long changelog
if: inputs.print_out_changelogs
id: print_out_long_changelog
shell: bash
run: |
cat "${{ inputs.long_changelog_export_filename }}"
- name: Display short changelog
if: inputs.print_out_changelogs
id: print_out_short_changelog
shell: bash
run: |
cat "${{ inputs.short_changelog_export_filename }}"
...