Skip to content

Added search

Added search #13

Workflow file for this run

name: Create Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get version from package.json
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: Update CHANGELOG.md and get changes
id: changelog
run: |
VERSION=${{ steps.package-version.outputs.current-version }}
TODAY=$(date +%Y-%m-%d)
# Update the date in CHANGELOG.md
sed -i "s/\[$VERSION\] - [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/[$VERSION] - $TODAY/" CHANGELOG.md
sed -i "s/\[$VERSION\] - YYYY-MM-DD/[$VERSION] - $TODAY/" CHANGELOG.md
# Extract changes for this version with updated date
CHANGES=$(sed -n "/## \[$VERSION\] - $TODAY/,/## \[/p" CHANGELOG.md | sed '$d')
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Commit CHANGELOG.md changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md with release date [skip ci]" || echo "No changes to commit"
git push
- name: Check if version already released
id: check_version
run: |
VERSION=${{ steps.package-version.outputs.current-version }}
if grep -q "\[$VERSION\]" CHANGELOG.md; then
echo "Version $VERSION already released. Exiting."
echo "version_exists=true" >> $GITHUB_ENV
else
echo "version_exists=false" >> $GITHUB_ENV
fi
- name: Create Release
if: ${{ steps.check_version.outputs.version_exists == 'false' }} # Check the output from the previous step
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
release_name: Release ${{ steps.package-version.outputs.current-version }}
body: ${{ steps.changelog.outputs.changes }}
draft: false
prerelease: false
# Add more steps here as needed, such as building and uploading artifacts