Enhance commit message generation by adding support for current branc… #14
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: Auto Release on Version Change | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Get Version from package.json | |
| id: get_version | |
| run: echo "version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Check if tag exists remotely | |
| id: check_tag | |
| run: | | |
| PACKAGE_VERSION="${{ steps.get_version.outputs.version }}" | |
| TAG_NAME="v${PACKAGE_VERSION}" # Standard v-prefix for tags | |
| echo "Checking for remote tag: ${TAG_NAME}" | |
| TAG_EXISTS_COUNT=$(git ls-remote --tags origin "refs/tags/${TAG_NAME}" | wc -l) | |
| if [ "$TAG_EXISTS_COUNT" -ne 0 ]; then | |
| echo "Tag ${TAG_NAME} already exists remotely." | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Tag ${TAG_NAME} does not exist remotely. Proceeding." | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| shell: bash | |
| - name: Inform if tag already exists (and skip release) | |
| if: steps.check_tag.outputs.exists == 'true' | |
| run: | | |
| PACKAGE_VERSION="${{ steps.get_version.outputs.version }}" | |
| TAG_NAME="v${PACKAGE_VERSION}" | |
| echo "::notice title=Tag Exists::Tag ${TAG_NAME} already exists. Skipping release and publish steps." | |
| shell: bash | |
| # --- Steps below will only run if the tag DOES NOT exist --- | |
| - name: Create Release (and Git Tag) | |
| if: steps.check_tag.outputs.exists == 'false' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| draft: false | |
| prerelease: false | |
| tag: v${{ steps.get_version.outputs.version }} | |
| name: Release v${{ steps.get_version.outputs.version }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Bun | |
| if: steps.check_tag.outputs.exists == 'false' | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies with Bun | |
| if: steps.check_tag.outputs.exists == 'false' | |
| run: bun install --frozen-lockfile | |
| - name: Publish to npm with Bun | |
| if: steps.check_tag.outputs.exists == 'false' | |
| run: bun publish | |
| env: | |
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} |