Skip to content

Commit

Permalink
[DEVOPS-1642] Add CHANGELOG automation (#49)
Browse files Browse the repository at this point in the history
Add CHANGELOG automation
  • Loading branch information
robwittman authored Sep 20, 2023
1 parent f0b2274 commit ac605bc
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,33 @@ jobs:
with:
push: ${{ github.event_name != 'pull_request' }}
targets: ${{ steps.target.outputs.TARGET }}

create_release:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-22.04
steps:
- name: Checkout the code
uses: actions/checkout@v3
with:
# We need to pull tags as well, so that we can
# grab the latest releases for changelog actions
fetch-depth: 0

# Get information from the CHANGELOG. By default,
# this action grabs the latest version
- name: Get latest CHANGELOG version
id: changelog_reader
uses: mindsers/changelog-reader-action@b97ce03a10d9bdbb07beb491c76a5a01d78cd3ef
with:
path: ./CHANGELOG.md

- name: Create/update release
uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5
with:
# This pulls from the "Get Changelog Entry" step above, referencing it's ID to get its outputs object.
# See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
tag: ${{ steps.changelog_reader.outputs.version }}
name: Release ${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
allowUpdates: false
token: ${{ secrets.NBL_GITHUB_PACKAGES_TOKEN }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.1] - 2023-09-20
### Added
- Added automatic release creation via CHANGELOG
12 changes: 11 additions & 1 deletion scripts/set-variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ PR_NUMBER=${3:-0}

TIMESTAMP=$(date)

# If 'main' or 'PR', we add a handle ('latest', 'pr-XXX') to the image
# We don't provide a handle for releases
if [[ "${REF}" == "main" ]]; then
echo "HANDLE=latest" >> "${GITHUB_ENV}"
elif [[ "${EVENT}" == "pull_request" ]]; then
echo "HANDLE=pr-${PR_NUMBER}" >> "${GITHUB_ENV}"
fi
echo "TAG=${GITHUB_SHA}" >> "${GITHUB_ENV}"

# If a release, we use the tag, otherwise we use the commit SHA
if [[ "${EVENT}" == "release" ]]; then
echo "TAG=${GITHUB_REF}" >> "${GITHUB_ENV}"
else
echo "TAG=${GITHUB_SHA}" >> "${GITHUB_ENV}"
fi

# Always output the timestamp for builds
echo "TIMESTAMP=${TIMESTAMP}" >> "${GITHUB_ENV}"

0 comments on commit ac605bc

Please sign in to comment.