bump to latest #49
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 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - 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: Configure git user | |
| run: | | |
| git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
| git config --global user.name "${{ github.actor }}" | |
| - name: Get latest version from git tags | |
| id: get_version | |
| run: | | |
| # Get the latest semantic version tag, default to 0.0.0 if none exists | |
| LATEST_TAG=$(git tag --list "v*" --sort=-version:refname | head -n1 || echo "v0.0.0") | |
| # Remove 'v' prefix and increment patch version | |
| VERSION=${LATEST_TAG#v} | |
| IFS='.' read -r major minor patch <<< "$VERSION" | |
| NEW_PATCH=$((patch + 1)) | |
| NEW_VERSION="${major}.${minor}.${NEW_PATCH}" | |
| echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT | |
| echo "Previous version: ${VERSION}, New version: ${NEW_VERSION}" | |
| - name: Update package.json version | |
| run: npm version ${{ steps.get_version.outputs.new_version }} --no-git-tag-commit | |
| - name: Publish to npm | |
| id: npm_publish | |
| run: | | |
| npm whoami | |
| 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" | |
| VERSION=${{ steps.package_version.outputs.version }} | |
| git tag v${VERSION} || echo "Tag v${VERSION} already exists" | |
| git push origin v${VERSION} |