diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c45e5a3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,63 @@ +name: Publish to npm + +on: + workflow_dispatch: + inputs: + confirm: + description: 'Type "publish" to confirm' + required: true + type: string + +jobs: + publish: + runs-on: ubuntu-latest + if: inputs.confirm == 'publish' + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run clean-build + + - name: Run tests + run: npm test + + - name: Publish to npm + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + # Use NPM_TOKEN if available, otherwise fall back to NODE_AUTH_TOKEN + if [ -n "$NPM_TOKEN" ]; then + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + fi + npm publish --access public + # Clean up + rm -f .npmrc + + - name: Get package version + id: package-version + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + + - name: Create success summary + run: | + echo "## ✅ Package Published Successfully" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Package:** turkey-map-react@${{ steps.package-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**npm:** https://www.npmjs.com/package/turkey-map-react" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6b4d0ff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ +name: Release + +on: + workflow_dispatch: + inputs: + release_type: + description: 'Release type' + required: true + default: 'patch' + type: choice + options: + - major + - minor + - patch + - prerelease + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Install dependencies + run: npm ci + + - name: Run release script + run: ./scripts/release.sh ${{ inputs.release_type }} + + - name: Push changes and tags + run: | + git push --follow-tags origin ${{ github.ref_name }} + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG_NAME=$(git describe --tags --abbrev=0) + CHANGELOG_CONTENT=$(awk -v ver="$TAG_NAME" ' + $0 ~ "## \\[?"ver {found=1; next} + /^## \[?[0-9]/ && found {exit} + found {print} + ' CHANGELOG.md | sed '/^$/d') + + if [ -z "$CHANGELOG_CONTENT" ]; then + CHANGELOG_CONTENT="Release $TAG_NAME" + fi + + gh release create "$TAG_NAME" \ + --title "$TAG_NAME" \ + --notes "$CHANGELOG_CONTENT" \ + --verify-tag diff --git a/.gitignore b/.gitignore index 87d2c95..aef3abb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules *.lock lib .idea +.npmrc diff --git a/.versionrc.json b/.versionrc.json new file mode 100644 index 0000000..ce57489 --- /dev/null +++ b/.versionrc.json @@ -0,0 +1,46 @@ +{ + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "hidden": true + }, + { + "type": "docs", + "hidden": false, + "section": "Documentation" + }, + { + "type": "style", + "hidden": true + }, + { + "type": "refactor", + "hidden": false, + "section": "Refactoring" + }, + { + "type": "perf", + "hidden": false, + "section": "Performance Improvements" + }, + { + "type": "test", + "hidden": false, + "section": "Tests" + } + ], + "commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}", + "compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}", + "issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}", + "userUrlFormat": "{{host}}/{{user}}", + "releaseCommitMessageFormat": "chore(release): {{currentTag}}", + "issuePrefixes": ["#"] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f1ab7b..5a3609b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,15 +5,55 @@ email, or any other method with the owners of this repository before making a ch Please note we have a code of conduct, please follow it in all your interactions with the project. +## Commit Message Convention + +This project uses [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages. This enables automated changelog generation and semantic versioning. + +### Format + +``` +(): + + + +