Skip to content

Commit ac605bc

Browse files
authored
[DEVOPS-1642] Add CHANGELOG automation (#49)
Add CHANGELOG automation
1 parent f0b2274 commit ac605bc

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,33 @@ jobs:
220220
with:
221221
push: ${{ github.event_name != 'pull_request' }}
222222
targets: ${{ steps.target.outputs.TARGET }}
223+
224+
create_release:
225+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
226+
runs-on: ubuntu-22.04
227+
steps:
228+
- name: Checkout the code
229+
uses: actions/checkout@v3
230+
with:
231+
# We need to pull tags as well, so that we can
232+
# grab the latest releases for changelog actions
233+
fetch-depth: 0
234+
235+
# Get information from the CHANGELOG. By default,
236+
# this action grabs the latest version
237+
- name: Get latest CHANGELOG version
238+
id: changelog_reader
239+
uses: mindsers/changelog-reader-action@b97ce03a10d9bdbb07beb491c76a5a01d78cd3ef
240+
with:
241+
path: ./CHANGELOG.md
242+
243+
- name: Create/update release
244+
uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5
245+
with:
246+
# This pulls from the "Get Changelog Entry" step above, referencing it's ID to get its outputs object.
247+
# See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
248+
tag: ${{ steps.changelog_reader.outputs.version }}
249+
name: Release ${{ steps.changelog_reader.outputs.version }}
250+
body: ${{ steps.changelog_reader.outputs.changes }}
251+
allowUpdates: false
252+
token: ${{ secrets.NBL_GITHUB_PACKAGES_TOKEN }}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [0.0.1] - 2023-09-20
8+
### Added
9+
- Added automatic release creation via CHANGELOG

scripts/set-variables.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@ PR_NUMBER=${3:-0}
1414

1515
TIMESTAMP=$(date)
1616

17+
# If 'main' or 'PR', we add a handle ('latest', 'pr-XXX') to the image
18+
# We don't provide a handle for releases
1719
if [[ "${REF}" == "main" ]]; then
1820
echo "HANDLE=latest" >> "${GITHUB_ENV}"
1921
elif [[ "${EVENT}" == "pull_request" ]]; then
2022
echo "HANDLE=pr-${PR_NUMBER}" >> "${GITHUB_ENV}"
2123
fi
22-
echo "TAG=${GITHUB_SHA}" >> "${GITHUB_ENV}"
24+
25+
# If a release, we use the tag, otherwise we use the commit SHA
26+
if [[ "${EVENT}" == "release" ]]; then
27+
echo "TAG=${GITHUB_REF}" >> "${GITHUB_ENV}"
28+
else
29+
echo "TAG=${GITHUB_SHA}" >> "${GITHUB_ENV}"
30+
fi
31+
32+
# Always output the timestamp for builds
2333
echo "TIMESTAMP=${TIMESTAMP}" >> "${GITHUB_ENV}"

0 commit comments

Comments
 (0)