change release note #46
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: release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: check out | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: get latest version | |
id: get_tag | |
run: | | |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
- name: Generate commit history | |
id: generate_notes | |
run: | | |
REPO_URL="https://github.com/$GITHUB_REPOSITORY/commit" | |
if [[ "${{ env.LATEST_TAG }}" == "0.0.0" ]]; then | |
COMMIT_LOG=$(git log --pretty=format:"- %s [#%h]($REPO_URL/%H)" --reverse) | |
else | |
COMMIT_LOG=$(git log ${{ env.LATEST_TAG }}..HEAD --pretty=format:"-%s [#%h]($REPO_URL/%H)" --reverse) | |
fi | |
NOTES=$(cat << EOF | |
$COMMIT_LOG | |
EOF | |
) | |
echo "$NOTES" > notes.md | |
cat notes.md | |
- name: bump version | |
id: bump_version | |
run: | | |
LATEST="${{ env.LATEST_TAG }}" | |
echo "Latest tag: $LATEST" | |
MAJOR=$(echo $LATEST | cut -d'.' -f1) | |
MINOR=$(echo $LATEST | cut -d'.' -f2) | |
PATCH=$(echo $LATEST | cut -d'.' -f3) | |
if git log -1 --pretty=%B | grep -iq "VERSION CHANGE"; then | |
MAJOR=$((MAJOR + 1)) | |
MINOR=0 | |
PATCH=0 | |
elif git log -1 --pretty=%B | grep -iq "feat:"; then | |
MINOR=$((MINOR + 1)) | |
PATCH=0 | |
else | |
PATCH=$((PATCH + 1)) | |
fi | |
NEW_TAG="$MAJOR.$MINOR.$PATCH" | |
echo "New tag: $NEW_TAG" | |
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | |
- name: create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ env.NEW_TAG }} \ | |
--title "${{ env.NEW_TAG }}" \ | |
--notes-file notes.md |