Skip to content

Update README & release 2.0.30 (#76) #1175

Update README & release 2.0.30 (#76)

Update README & release 2.0.30 (#76) #1175

Workflow file for this run

name: Release
on:
push:
branches:
- master
paths-ignore:
- CHANGELOG.md
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: Report coverage
uses: qltysh/qlty-action/coverage@v2
with:
token: '${{secrets.QLTY_COVERAGE_TOKEN}}'
files: coverage/lcov.info
- 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
outputs:
commit_hash: '${{ steps.committing.outputs.commit_hash }}'
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: |
changelog=""
# Get tags newest to oldest
tags=($(git tag --sort=-version:refname))
# Untagged commits after latest tag
if [ "${#tags[@]}" -gt 0 ]; then
latest_tag="${tags[0]}"
untagged_commits=$(git --no-pager log --format="%s (%an) [%h]" "${latest_tag}..HEAD")
else
untagged_commits=$(git --no-pager log --format="%s (%an) [%h]")
fi
# Get future version from package.json
future_tag="$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json)"
if [ -n "$untagged_commits" ]; then
tag_log="### ${future_tag}\n"
while IFS= read -r commit; do
tag_log+="- ${commit}\n"
done <<< "$untagged_commits"
changelog="${tag_log}\n${changelog}"
fi
# Loop from i=0 to i <= tags.length (YES, intentionally +1)
for ((i=0; i<=${#tags[@]}; i++)); do
current="${tags[$i]}"
next="${tags[$((i+1))]}"
# Skip if current is empty (e.g., i == len)
if [ -z "$current" ]; then
continue
fi
if [ -n "$next" ]; then
commits=$(git --no-pager log --format="%s (%an) [%h]" "${next}..${current}")
else
# last tag (oldest), no previous one
commits=$(git --no-pager log --format="%s (%an) [%h]" "${current}")
fi
if [ -n "$commits" ]; then
tag_log="### ${current}\n"
while IFS= read -r commit; do
tag_log+="- ${commit}\n"
done <<< "$commits"
changelog="${changelog}\n${tag_log}"
fi
done
changelog="# Changelog\n${changelog}"
echo -e "$changelog"
printf '%b' "$changelog" > CHANGELOG.md
- name: Upload new changelog
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md
- name: Commit and push the new changelog
id: committing
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"
commit_hash=$( git --no-pager log -1 --format=%H )
echo "commit_hash=${commit_hash}" >> "$GITHUB_OUTPUT"
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]
outputs:
tagname: '${{ steps.tagging.outputs.tagname }}'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
ref: '${{ needs.changelog.outputs.commit_hash }}'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Maybe generate tag
uses: Klemensas/action-autotag@stable
id: tagging
with:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
tag_prefix: ''
tag_suffix: ''
changelog_structure: "**{{messageHeadline}}** {{author}}\n"
trigger_publish:
name: Maybe trigger publish
runs-on: ubuntu-latest
needs: [maybe_tag]
if: ${{ needs.maybe_tag.outputs.tagname != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
fetch-tags: 'true'
- name: Trigger the publish workflow
run: gh workflow run publish.yml --ref ${{ needs.maybe_tag.outputs.tagname }}
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
trigger_release:
name: Maybe trigger GitHub release
runs-on: ubuntu-latest
needs: [maybe_tag]
if: ${{ needs.maybe_tag.outputs.tagname != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
set-safe-directory: 'true'
fetch-tags: 'true'
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
token: '${{ secrets.GITHUB_TOKEN }}'
tag: '${{ needs.maybe_tag.outputs.tagname }}'
generateReleaseNotes: true
allowUpdates: true
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'