Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/astro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
name: Deploy Astro site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
release:
types: [published]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: update-changelog

on:
release:
types: [published]

jobs:
update:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# updated CHANGELOG back to the repository.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v5
with:
# Fetch entire history of repository to ensure relase date can be
# extracted from commit of the given tag.
fetch-depth: 0
# Checkout target branch of this release. Ensures that the CHANGELOG
# is not out of date.
ref: ${{ github.event.release.target_commitish }}

- name: Check if branch and release match
if: ${{ github.event.release.target_commitish != 'main' && github.event.release.target_commitish != 'master' }}
id: guard
run: |
NUMERIC_VERSION="${RELEASE_TAG_NAME#v}"
MAJOR_VERSION="${NUMERIC_VERSION%%.*}"
BRANCH_MAJOR_VERSION="${BRANCH%%.*}"

echo "MAJOR_VERSION=$(echo $MAJOR_VERSION)" >> $GITHUB_OUTPUT;
echo "BRANCH_MAJOR_VERSION=$(echo $BRANCH_MAJOR_VERSION)" >> $GITHUB_OUTPUT;

if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then
echo "Mismatched versions! Aborting."
VERSION_MISMATCH='true';
else
echo "Versions match! Proceeding."
VERSION_MISMATCH='false';
fi
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> $GITHUB_OUTPUT;
env:
BRANCH: ${{ github.event.release.target_commitish }}
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}

- name: Fail if branch and release tag do not match
if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Workflow failed. Release version does not match with selected target branch. Changelog not updated automatically.')

- name: Extract release date from git tag
id: release_date
run: |
# Get UNIX timestamp from git-tag
TIMESTAMP_OF_RELEASE_COMMIT=$(git log -1 --date=unix --format=%ad '${{ github.event.release.tag_name }}');

# Convert timestamp to UTC date in Y-m-d format
FORMATED_DATE=$(date -u -d @$TIMESTAMP_OF_RELEASE_COMMIT +%Y-%m-%d)

# Make date available to other steps
echo "date=$(echo $FORMATED_DATE)" >> $GITHUB_OUTPUT;

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
# Pass extracted release date, release notes and version to the Action.
release-date: ${{ steps.release_date.outputs.date }}
release-notes: ${{ github.event.release.body }}
latest-version: ${{ github.event.release.tag_name }}
compare-url-target-revision: ${{ github.event.release.target_commitish }}
parse-github-usernames: true

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v6
with:
# Push updated CHANGELOG to release target branch.
branch: ${{ github.event.release.target_commitish }}
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Release Notes
Loading