Skip to content

Commit 512b310

Browse files
added generate-release-notes-from-changelog task
1 parent 3fd24dc commit 512b310

File tree

3 files changed

+116
-4
lines changed

3 files changed

+116
-4
lines changed

README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Common Concourse Pipeline Tasks
55

66
All examples use the following resources:
77

8-
```
8+
```yaml
99
resource_types:
1010
- name: cf-cli-resource
1111
type: docker-image
1212
source:
13-
repository: patrickcrocker/cf-cli-resource
14-
tag: 2.0.0
13+
repository: pivotalpa/cf-cli-resource
14+
tag: latest
1515

1616
resources:
1717
- name: pipeline-tasks
@@ -33,7 +33,7 @@ resources:
3333
3434
## Generate a Cloud Foundry Manifest
3535
36-
```
36+
```yaml
3737
- name: test
3838
plan:
3939
- aggregate:
@@ -57,3 +57,42 @@ resources:
5757
path: artifact/myapp-*.jar
5858
current_app_name: {{cf-test-app-name}}
5959
```
60+
61+
## Generate release information
62+
63+
This example showcases tasks commonly used with [github-release](https://github.com/concourse/github-release-resource):
64+
* `generate-github-release`: Generates a version string (ex: v1.0.0) for the `release-name` and `release-tag` files.
65+
* `generate-commitish`: Generates the [commitish](https://stackoverflow.com/questions/23303549/what-are-commit-ish-and-tree-ish-in-git) file.
66+
* `generate-release-notes`: Generates the release notes for a particular version by parsing a change log format based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
67+
68+
```yaml
69+
- name: shipit
70+
serial_groups: [version]
71+
plan:
72+
- aggregate:
73+
- get: pipeline-tasks
74+
- get: project
75+
passed: [build]
76+
- get: version
77+
passed: [build]
78+
params: {bump: final}
79+
- task: generate-github-release
80+
file: pipeline-tasks/generate-github-release/task.yml
81+
output_mapping: {task-output: generate-github-release-output}
82+
- task: generate-commitish
83+
file: pipeline-tasks/generate-commitish/task.yml
84+
output_mapping: {task-output: generate-commitish-output}
85+
- task: generate-release-notes
86+
file: pipeline-tasks/generate-release-notes-from-changelog/task.yml
87+
input-mapping: {task-input: project}
88+
output-mapping: {task-output: generate-release-notes-output}
89+
- put: github-release
90+
params:
91+
name: generate-github-release-output/release-name
92+
tag: generate-github-release-output/release-tag
93+
commitish: generate-commitish-output/commitish
94+
body: generate-release-notes-output/RELEASE_NOTES.md
95+
- put: version
96+
params: {file: version/version}
97+
98+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
set -o pipefail
5+
6+
[ 'true' = "${DEBUG:-}" ] && set -x
7+
8+
: "${CHANGELOG_FILE:?not set or empty}"
9+
: "${VERSION_FILE:?not set or empty}"
10+
: "${RELEASE_NOTES_FILE:?not set or empty}"
11+
12+
function error_and_exit() {
13+
local message=${1:-<no message set>}
14+
echo "ERROR: $message" >&2
15+
exit 1
16+
}
17+
18+
[ ! -f "version/$VERSION_FILE" ] && error_and_exit "version file does not exist: version/$VERSION_FILE"
19+
version=$(cat "version/$VERSION_FILE")
20+
21+
[ ! -f "task-input/$CHANGELOG_FILE" ] && error_and_exit "changelog file does not exist: task-input/$CHANGELOG_FILE"
22+
capture=false
23+
content=
24+
while read line; do
25+
26+
# Matches variations of start line: ## [2.0.0] - some other text
27+
if ! $capture && echo $line | grep -oEq "^##\s\[{0,}$version]{0,}\s{0,}.*$"; then
28+
capture=true
29+
fi
30+
31+
# Matches variations of stop line: ## [1.0.0] - some other text
32+
if $capture && [ -n "$content" ] && echo $line | grep -oEq "^##\s\[{0,}.*]{0,}\s{0,}.*$"; then
33+
capture=false
34+
fi
35+
36+
# Matches markdown links at bottom of file: [1.0.0]: https://...
37+
if $capture && [ -n "$content" ] && echo $line | grep -oEq "^\[.*$"; then
38+
capture=false
39+
fi
40+
41+
[ $capture = true ] && content+="$line"$'\n'
42+
43+
done <"task-input/$CHANGELOG_FILE"
44+
45+
echo "$content" > task-output/${RELEASE_NOTES_FILE}
46+
47+
echo "Release Notes:"
48+
echo "-------------"
49+
cat task-output/${RELEASE_NOTES_FILE}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
platform: linux
3+
4+
image_resource:
5+
type: docker-image
6+
source:
7+
repository: concourse/git-resource
8+
9+
params:
10+
CHANGELOG_FILE: CHANGELOG.md
11+
VERSION_FILE: version
12+
RELEASE_NOTES_FILE: RELEASE_NOTES.md
13+
DEBUG: false
14+
15+
inputs:
16+
- name: pipeline-tasks
17+
- name: task-input
18+
- name: version
19+
20+
outputs:
21+
- name: task-output
22+
23+
run:
24+
path: pipeline-tasks/generate-release-notes-from-changelog/task.sh

0 commit comments

Comments
 (0)