chore: fix release tagging for @devvit/mcp publishing #40
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: CD | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build-test-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| scope: '@devvit' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Install deps | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Run checks (linting, type-checking, formatting) | |
| run: npm run check | |
| - name: Ensure repo is clean after checks | |
| run: git diff --exit-code | |
| - name: Run tests | |
| run: npm run test | |
| - name: Bump version locally (not committed) | |
| run: npm version patch -m "chore(release)" | |
| - name: Publish to npm | |
| id: npm_publish | |
| run: | | |
| npm publish --access public | |
| - name: Get package version | |
| id: package_version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create release tag | |
| id: create_tag | |
| if: steps.npm_publish.outcome == 'success' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Check if the tag already exists remotely or locally | |
| if git rev-parse "refs/tags/v${{ steps.package_version.outputs.version }}" >/dev/null 2>&1 || \ | |
| git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.package_version.outputs.version }}$"; then | |
| echo "Tag v${{ steps.package_version.outputs.version }} already exists. Skipping tag creation." | |
| else | |
| git tag v${{ steps.package_version.outputs.version }} | |
| git push origin v${{ steps.package_version.outputs.version }} | |
| fi |