Skip to content

Update the project changelog #1151

Update the project changelog

Update the project changelog #1151

Workflow file for this run

name: Release
on:
push:
branches:
- master
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Lint the codebase
run: npm run lint:ci
test_and_report_coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run tests
run: npm run test:ci
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: test_coverage
path: coverage
build_code:
name: Build code
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build code
run: npm run build:ci
- name: Upload the dist folder
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
integration_tests:
name: Run integration tests
runs-on: ubuntu-latest
needs: build_code
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Download dist/ folder
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Run integration tests
run: npm run test:integration:ci
build_docs:
name: Build Docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build storybook
run: npm run docs:ci
- name: Upload the docs
uses: actions/upload-artifact@v4
with:
name: docs
path: docs
changelog:
name: Generate new changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
ssh-key: '${{ secrets.SSH_PRIVATE_KEY }}'
persist-credentials: 'true'
fetch-tags: 'true'
fetch-depth: 0
- name: Generate changelog
run: |
initial_commit=$( git log --reverse --format='%H' | head -n 1 )
printf '\n\ninitial_commit=%s\n\n' "${initial_commit[@]}"
output=''
for tag in $( git tag -l | sort -V ); do
printf 'Processing tag=%s\n' "${tag[@]}"
commits=$( git log --reverse --format='- (%h) %s (%an)' "${initial_commit}".."${tag}" )
if [ ${#commits[@]} -eq 0 ]; then
commits=$( git log --reverse --format='- (%h) %s (%an)' | head -n 1 )
fi
printf 'commits=<<<COMMITS\n%s\nCOMMITS\n' "${commits[@]}"
section=$( printf '%s\n%s' "## v${tag}" "${commits}" )
initial_commit="${tag}"
step_output=$( printf '%s\n\n' "${section}" )
printf 'version_changelog=<<<CHUNK\n%s\nCHUNK\n\n' "${step_output[@]}"
output=$( printf '%s\n\n' "${step_output}" "${output}" )
done
package_version=$( cat package.json | grep "version" | grep -oE '[0-9.]+' )
last_tag=$( git tag -l | tail -n 1 )
printf 'package_version=%s\nlast_tag=%s\n' "${package_version[@]}" "${last_tag[@]}"
if [ "${package_version}" != "${last_tag}" ]; then
commits=$( git log --reverse --format='- (%h) %s (%an)' "${last_tag}"..HEAD )
if [ ${#commits[@]} -ne 0 ]; then
section=$( printf '%s\n%s' "## v${package_version}" "${commits}" )
output=$( printf '%s\n\n' "${section}" "${output}" )
fi
fi
printf 'Changelog=<<<CHANGELOG\n%s\nCHANGELOG\n\n' "${output[@]}"
printf '%s\n' "${output}" > CHANGELOG.md
- name: Upload new changelog
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md
- name: Commit and push the new changelog
run: |
if [ -z $(git status -uno --porcelain) ]; then
printf 'Changelogs are identical, nothing to commit\n'
else
printf 'Committing the updated changelog\n'
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git commit -am "Update the project changelog"
fi
- name: Push changes
uses: ad-m/[email protected]
with:
ssh: true
branch: '${{ github.ref }}'
maybe_tag:
name: Maybe tag the release
runs-on: ubuntu-latest
needs: [lint, test_and_report_coverage, build_code, build_docs, integration_tests, changelog]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Maybe generate tag
uses: Klemensas/action-autotag@stable
with:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
tag_prefix: ''
tag_suffix: ''
changelog_structure: "**{{messageHeadline}}** {{author}}\n"