Skip to content

Commit

Permalink
feat: update GitHub Actions workflow to version and publish packages …
Browse files Browse the repository at this point in the history
…with semantic release
  • Loading branch information
bucurdavid committed Feb 14, 2025
1 parent 152d5f6 commit 2be3e8c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
45 changes: 32 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:
contents: write

jobs:
publish-npm:
version-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -28,8 +28,8 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '23.3.x'
registry-url: https://registry.npmjs.org/
node-version: '20.x'
registry-url: 'https://registry.npmjs.org/'

- name: Install pnpm
uses: pnpm/action-setup@v2
Expand Down Expand Up @@ -63,18 +63,37 @@ jobs:
pnpm run build:stable
fi
- name: Setup Semantic Release
- name: Get Next Version
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm add -D semantic-release
OUTPUT=$(unset GITHUB_ACTIONS && npx semantic-release --dry-run --no-ci)
VERSION=$(echo "$OUTPUT" | grep -o "The next release version is [0-9]*\.[0-9]*\.[0-9]*" | awk '{print $6}')
if [[ "${{ steps.release_type.outputs.type }}" == "alpha" ]]; then
VERSION="${VERSION}-alpha.$(date +%s)"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Update Version
run: |
pnpm add -D semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
npm version ${{ steps.semantic.outputs.version }} --no-git-tag-version
- name: Semantic Release
- name: Publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
RELEASE_TYPE="${{ steps.release_type.outputs.type }}"
if [[ "$RELEASE_TYPE" == "alpha" ]]; then
npx semantic-release --branches develop --preset conventionalcommits --prerelease alpha
if [[ "${{ steps.release_type.outputs.type }}" == "alpha" ]]; then
pnpm publish --access=public --tag alpha --no-git-checks
else
npx semantic-release --branches main --preset conventionalcommits
fi
pnpm publish --access=public --no-git-checks
fi
- name: Create Git Tag
if: success()
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git tag -a "v${{ steps.semantic.outputs.version }}" -m "Release v${{ steps.semantic.outputs.version }}"
git push origin "v${{ steps.semantic.outputs.version }}"
1 change: 0 additions & 1 deletion dist/index.js.map

This file was deleted.

0 comments on commit 2be3e8c

Please sign in to comment.