Skip to content

CD

CD #73

Workflow file for this run

name: CD
on:
workflow_run:
workflows: ["CI"]
types: [completed]
permissions:
contents: write
jobs:
release:
# Only release when CI succeeded for a direct push to main/master,
# and avoid infinite loops from the bot's own release commit.
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
(github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'master') &&
github.event.workflow_run.actor.login != 'github-actions[bot]' &&
contains(github.event.workflow_run.head_commit.message, 'release')
runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout tested branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump patch version + create tag
run: 'npm version patch -m "chore(release): %s [skip-release]"'
- name: Push version commit + tag
run: git push origin HEAD:${{ github.event.workflow_run.head_branch }} --follow-tags
- name: Get new version
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
generate_release_notes: true