chore: bump version to 1.0.37 #22
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: ctw-kit | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'ctw-kit/**' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
release-and-publish: | |
runs-on: ubuntu-24.04 | |
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.head_commit != null && !contains(github.event.head_commit.author.email, '[email protected]')) }} | |
defaults: | |
run: | |
working-directory: ctw-kit | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT_TOKEN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Bump version | |
id: bump-version | |
run: | | |
# Temporarily modify root package.json to remove workspace config | |
cd .. | |
cp package.json package.json.backup | |
jq 'del(.workspaces)' package.json > temp.json && mv temp.json package.json | |
cd ctw-kit | |
npm version patch --no-git-tag-version | |
NEW_VERSION=$(node -p "require('./package.json').version") | |
PACKAGE_NAME=$(node -p "require('./package.json').name") | |
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT | |
# Check if new version already exists | |
if npm view $PACKAGE_NAME@$NEW_VERSION version >/dev/null 2>&1; then | |
echo "Version $NEW_VERSION already exists in npm registry for package $PACKAGE_NAME" | |
exit 1 | |
fi | |
- name: Commit version bump | |
run: | | |
# Restore root package.json | |
cd .. | |
mv package.json.backup package.json | |
cd ctw-kit | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add package.json | |
git commit -m "chore: bump version to ${{ steps.bump-version.outputs.new_version }}" | |
git push origin HEAD:main | |
- name: Create Git tag | |
run: | | |
if [ -z "$(git tag -l '${{ steps.bump-version.outputs.new_version }}')" ]; then | |
git tag ${{ steps.bump-version.outputs.new_version }} | |
git push origin ${{ steps.bump-version.outputs.new_version }} | |
else | |
echo "Tag ${{ steps.bump-version.outputs.new_version }} already exists" | |
exit 1 | |
fi | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
with: | |
tag_name: ${{ steps.bump-version.outputs.new_version }} | |
release_name: Release ${{ steps.bump-version.outputs.new_version }} | |
draft: false | |
prerelease: false | |
- uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: | | |
cd .. | |
cp package.json package.json.backup | |
jq 'del(.workspaces)' package.json > temp.json && mv temp.json package.json | |
cd ctw-kit | |
bun install | |
# Restore root package.json | |
cd .. | |
mv package.json.backup package.json | |
cd ctw-kit | |
- name: Build | |
run: bun run build | |
- name: Publish to npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
if ! npm publish --access public 2>&1 | grep -q "EOTP"; then | |
echo "Package published successfully" | |
else | |
echo "Error: npm requires 2FA. Please check your npm account settings:" | |
echo "1. Go to npmjs.com → Profile Settings → Authentication & Authorization" | |
echo "2. Under 'Two-Factor Authentication', ensure it's not set to 'Required for all operations'" | |
exit 1 | |
fi |