Skip to content

0.2.3

0.2.3 #8

Workflow file for this run

name: update changelog
on:
release:
types: [released]
workflow_call:
secrets:
GPG_BOT:
required: true
description: bot gpg token
GPG_PASSPHRASE:
required: true
description: bot gpg passphrase
GPG_FINGERPRINT:
required: true
description: bot gpg fingerprint
BOT_TOKEN:
required: true
description: bot token
jobs:
changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.release.target_commitish }}
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v3
with:
files: "changelog.md"
- uses: actions/setup-go@v5
id: artifacts-golang
with:
go-version: '^1.21.0'
- name: Install first-changelog
id: artifacts-tools-install
if: steps.check_files.outputs.files_exists != 'true'
run: go install github.com/bavix/first-changelog@latest
- name: Install ghmd
run: go install github.com/bavix/ghmd@latest
- name: Init changelog
id: artifacts-display-all
if: steps.check_files.outputs.files_exists != 'true'
run: |
~/go/bin/first-changelog "${{ github.repository }}" > changelog.md
- name: Fix changelog
run: cat changelog.md | ~/go/bin/ghmd | tee changelog.md
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_BOT }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
fingerprint: ${{ secrets.GPG_FINGERPRINT }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: Github bot
git_committer_email: [email protected]
- name: Check if branch and release match
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
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: Extract release date from git tag
id: release_date
if: steps.check_files.outputs.files_exists == 'true'
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.md
uses: stefanzweifel/changelog-updater-action@v1
if: steps.check_files.outputs.files_exists == 'true'
with:
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
path-to-changelog: changelog.md
- name: Commit updated changelog.md
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: Update changelog.md
file_pattern: changelog.md
commit_user_name: Github bot
commit_user_email: [email protected]
commit_author: Github bot <[email protected]>
commit_options: '-S'