Update README.md #2
Workflow file for this run
This file contains hidden or 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: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
jobs: | |
create-release: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Determine new version | |
id: version | |
run: | | |
CURRENT_VERSION="0.3.0" | |
# Check commit messages to determine version increment | |
COMMITS=$(git log $(git describe --tags --abbrev=0 2>/dev/null || echo HEAD~10)..HEAD --pretty=format:"%s") | |
MAJOR_CHANGE=false | |
MINOR_CHANGE=false | |
PATCH_CHANGE=true # Default to patch if no specific keywords found | |
echo "$COMMITS" | while read -r commit; do | |
if [[ "$commit" == *"BREAKING CHANGE"* || "$commit" == *"!:"* ]]; then | |
MAJOR_CHANGE=true | |
break | |
elif echo "$commit" | grep -Eq "^feat(\([^)]+\))?:.*"; then | |
MINOR_CHANGE=true | |
fi | |
done | |
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
if [ "$MAJOR_CHANGE" = true ]; then | |
MAJOR=$((MAJOR + 1)) | |
MINOR=0 | |
PATCH=0 | |
elif [ "$MINOR_CHANGE" = true ]; then | |
MINOR=$((MINOR + 1)) | |
PATCH=0 | |
else | |
PATCH=$((PATCH + 1)) | |
fi | |
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
echo "New version: $NEW_VERSION" | |
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
echo "release_tag=v$NEW_VERSION" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.version.outputs.release_tag }} | |
release_name: Release ${{ steps.version.outputs.release_tag }} | |
draft: false | |
prerelease: false | |
body: | | |
Release ${{ steps.version.outputs.release_tag }} | |
Changes in this release: | |
${{ github.event.pull_request.title }} (#${{ github.event.pull_request.number }}) |