Refactor: All docs #34
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: Build and Release | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js and pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Get commit message | |
id: commit_message | |
run: echo "::set-output name=MESSAGE::$(git log --format=%B -n 1 ${{ github.sha }})" | |
- name: Install yq | |
run: sudo apt-get install yq | |
- name: Parse commit message and update version | |
id: update_version | |
run: | | |
COMMIT_MESSAGE="${{ steps.commit_message.outputs.MESSAGE }}" | |
CURRENT_VERSION=$(cat.github/version.yml | yq eval '.version' -) | |
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) | |
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) | |
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3) | |
if [[ $COMMIT_MESSAGE == "First"* ]]; then | |
MAJOR=1 | |
MINOR=0 | |
PATCH=0 | |
elif [[ $COMMIT_MESSAGE == "Fix"* ]]; then | |
PATCH=$((PATCH + 1)) | |
elif [[ $COMMIT_MESSAGE == "Feat"* ]]; then | |
MINOR=$((MINOR + 1)) | |
PATCH=0 | |
elif [[ $COMMIT_MESSAGE == "Refactor"* ]]; then | |
MAJOR=$((MAJOR + 1)) | |
MINOR=0 | |
PATCH=0 | |
else | |
echo "No version update needed for other commit types" | |
echo "::set-output name=NEW_VERSION::null" | |
exit 0 # Exit successfully without creating a release | |
fi | |
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
echo "Updating version from $CURRENT_VERSION to $NEW_VERSION" | |
echo "::set-output name=NEW_VERSION::$NEW_VERSION" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
if: steps.update_version.outputs.NEW_VERSION!= 'null' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.update_version.outputs.NEW_VERSION }} | |
release_name: Release ${{ steps.update_version.outputs.NEW_VERSION }} | |
draft: false | |
prerelease: false |