Skip to content

Commit 29998f7

Browse files
committed
refactor(github): simplified workflow
Signed-off-by: Fred Myerscough <oniice@gmail.com>
1 parent 339146b commit 29998f7

1 file changed

Lines changed: 5 additions & 69 deletions

File tree

.github/workflows/update-changelog.yml

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@ name: update changelog
22

33
on:
44
workflow_call:
5-
inputs:
6-
branch:
7-
description: 'Target branch'
8-
default: ${{ github.event.release.target_commitish }}
9-
type: string
10-
version:
11-
description: 'Released version'
12-
default: ${{ github.event.release.tag_name }}
13-
type: string
14-
notes:
15-
description: 'Release notes'
16-
default: ${{ github.event.release.body }}
17-
type: string
185

196
jobs:
207
update:
@@ -24,69 +11,18 @@ jobs:
2411
- name: Checkout code
2512
uses: actions/checkout@v4
2613
with:
27-
# Fetch entire history of repository to ensure release date can be
28-
# extracted from commit of the given tag.
2914
fetch-depth: 0
30-
# Checkout target branch of this release. Ensures that the CHANGELOG
31-
# is not out of date.
32-
ref: ${{ inputs.branch }}
33-
34-
- name: Check if branch and release match
35-
if: ${{ inputs.branch != 'main' && inputs.branch != 'master' }}
36-
id: guard
37-
run: |
38-
NUMERIC_VERSION="${RELEASE_TAG_NAME#v}"
39-
MAJOR_VERSION="${NUMERIC_VERSION%%.*}"
40-
BRANCH_MAJOR_VERSION="${BRANCH%%.*}"
41-
42-
echo "MAJOR_VERSION=$(echo $MAJOR_VERSION)" >> $GITHUB_OUTPUT;
43-
echo "BRANCH_MAJOR_VERSION=$(echo $BRANCH_MAJOR_VERSION)" >> $GITHUB_OUTPUT;
44-
45-
if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then
46-
echo "Mismatched versions! Aborting."
47-
VERSION_MISMATCH='true';
48-
else
49-
echo "Versions match! Proceeding."
50-
VERSION_MISMATCH='false';
51-
fi
52-
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> $GITHUB_OUTPUT;
53-
env:
54-
BRANCH: ${{ inputs.branch }}
55-
RELEASE_TAG_NAME: ${{ inputs.version }}
56-
57-
- name: Fail if branch and release tag do not match
58-
if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }}
59-
uses: actions/github-script@v7
60-
with:
61-
script: |
62-
core.setFailed('Workflow failed. Release version does not match with selected target branch. Changelog not updated automatically.')
63-
64-
- name: Extract release date from git tag
65-
id: release_date
66-
run: |
67-
# Get UNIX timestamp from git-tag
68-
TIMESTAMP_OF_RELEASE_COMMIT=$(git log -1 --date=unix --format=%ad '${{ inputs.version }}');
69-
70-
# Convert timestamp to UTC date in Y-m-d format
71-
FORMATED_DATE=$(date -u -d @$TIMESTAMP_OF_RELEASE_COMMIT +%Y-%m-%d)
72-
73-
# Make date available to other steps
74-
echo "date=$(echo $FORMATED_DATE)" >> $GITHUB_OUTPUT;
15+
ref: main
7516

7617
- name: Update Changelog
7718
uses: stefanzweifel/changelog-updater-action@v1
7819
with:
79-
# Pass extracted release date, release notes and version to the Action.
80-
release-date: ${{ steps.release_date.outputs.date }}
81-
release-notes: ${{ inputs.notes }}
82-
latest-version: ${{ inputs.version }}
83-
compare-url-target-revision: ${{ inputs.branch }}
84-
parse-github-usernames: true
20+
latest-version: ${{ github.event.release.tag_name }}
21+
release-notes: ${{ github.event.release.body }}
8522

8623
- name: Commit updated CHANGELOG
8724
uses: stefanzweifel/git-auto-commit-action@v7
8825
with:
89-
# Push updated CHANGELOG to release target branch.
90-
branch: ${{ inputs.branch }}
91-
commit_message: Update CHANGELOG
26+
branch: main
27+
commit_message: 'chore: update CHANGELOG'
9228
file_pattern: CHANGELOG.md

0 commit comments

Comments
 (0)