chore: version packages #84
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: Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Create release PR or publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: npm run release | |
| version: npm run version-packages | |
| title: "chore: version packages" | |
| commit: "chore: version packages" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Rename release tag to codeman | |
| if: steps.changesets.outputs.published == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| OLD_TAG="aicodeman@${VERSION}" | |
| NEW_TAG="codeman@${VERSION}" | |
| # Update the GitHub release BEFORE deleting the old tag | |
| RELEASE_ID=$(gh release view "$OLD_TAG" --json databaseId -q .databaseId 2>/dev/null || true) | |
| if [ -n "$RELEASE_ID" ]; then | |
| gh api -X PATCH "repos/${{ github.repository }}/releases/${RELEASE_ID}" \ | |
| -f tag_name="$NEW_TAG" \ | |
| -f name="$NEW_TAG" | |
| fi | |
| # Retag | |
| git tag "$NEW_TAG" "$OLD_TAG" 2>/dev/null || true | |
| git tag -d "$OLD_TAG" 2>/dev/null || true | |
| git push origin "$NEW_TAG" ":refs/tags/$OLD_TAG" 2>/dev/null || true |