Update README.MD #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
push: | |
branches: ["main"] | |
paths: | |
- 'package.json' | |
pull_request: | |
branches: ["main"] | |
paths: | |
- 'package.json' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get Version from package.json | |
id: package_version | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=v${VERSION}" >> $GITHUB_ENV | |
- name: Check if tag exists | |
id: check_tag | |
run: | | |
if git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then | |
echo "Tag already exists, skipping release" | |
echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Get Changelog | |
if: env.TAG_EXISTS == 'false' | |
id: changelog | |
run: | | |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
if [ -z "$PREV_TAG" ]; then | |
CHANGELOG=$(git log --pretty=format:'- %s') | |
else | |
CHANGELOG=$(git log --pretty=format:'- %s' ${PREV_TAG}..HEAD) | |
fi | |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
echo "$CHANGELOG" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create Git Tag | |
if: env.TAG_EXISTS == 'false' | |
run: | | |
git tag ${{ env.VERSION }} | |
git push origin ${{ env.VERSION }} | |
- name: Create GitHub Release | |
if: env.TAG_EXISTS == 'false' | |
uses: softprops/[email protected] | |
with: | |
tag_name: ${{ env.VERSION }} | |
body: | | |
## Changelog | |
${{ env.CHANGELOG }} | |
prerelease: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |