-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: creating workflow for tagging merges
- Loading branch information
1 parent
84385d2
commit 2629729
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Semantic Version and Create GitHub Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: 'npm' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm version ${{ github.event.inputs.releaseType || 'latest' }} | ||
- name: Generate Git Tag | ||
id: generate_tag | ||
run: | | ||
VERSION_PREFIX="v" | ||
VERSION_MAJOR_MINOR="1.0" | ||
VERSION_PATCH=$(git tag --list "${VERSION_PREFIX}${VERSION_MAJOR_MINOR}.*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+$') | ||
if [ -z "$VERSION_PATCH" ]; then | ||
VERSION_PATCH=0 | ||
else | ||
VERSION_PATCH=$((VERSION_PATCH + 1)) | ||
fi | ||
NEW_TAG="${VERSION_PREFIX}${VERSION_MAJOR_MINOR}.${VERSION_PATCH}" | ||
echo "Generated new tag: $NEW_TAG" | ||
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | ||
- name: Push Git Tag | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
git tag $NEW_TAG | ||
git push origin $NEW_TAG |