Skip to content

chore: release v2.3.0 #28

chore: release v2.3.0

chore: release v2.3.0 #28

Workflow file for this run

name: Create Release
on:
push:
branches: [$default-branch]
tags: ["v*"]
pull_request:
branches: [$default-branch]
types: [closed]
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
# triggered when a new tag is pushed or a PR is merged into 'main'
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
steps:
- name: Checkout code
uses: actions/checkout@v4
# NOTE: if you want to reuse commit messages as release note's body
# NOTE: fetch all code history
with:
fetch-depth: 0
# this step outputs the version
# refer to it as ${{ steps.get_version.outputs.version }}`
- name: Check if current version is the same as the latest version
id: check_version
if: hashFiles('package.json') != ''
run: |
VERSION="v$(jq -r '.version' package.json)"
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
LATEST_VERSION=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
if [[ "${VERSION}" == "${LATEST_VERSION}" ]]; then
echo "skip_release=true" >> ${GITHUB_OUTPUT}
else
echo "skip_release=false" >> ${GITHUB_OUTPUT}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: steps.check_version.outputs.skip_release == 'false'
run: |
LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName // ""')
if [[ -n "$LATEST_TAG" ]]; then
COMMIT_RANGE="${LATEST_TAG}..HEAD"
else
COMMIT_RANGE="HEAD"
fi
echo "## What's Changed" > release_notes.md
echo "" >> release_notes.md
git log $COMMIT_RANGE --pretty=format:"* %s%b" --reverse >> release_notes.md
# Also add auto-generated notes for PR info
echo "" >> release_notes.md
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LATEST_TAG}...${{ steps.check_version.outputs.version }}" >> release_notes.md
gh release create \
${{ steps.check_version.outputs.version }} \
--title ${{ steps.check_version.outputs.version }} \
--fail-on-no-commits \
--verify-tag \
--target main \
--notes-file release_notes.md \
--latest \
source.sh script.sh template.sh template_lite.sh clone_bash_template.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}