Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/slow-seas-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@clinwise/release-scribe": minor
---

Add a real publish target so the Release Scribe flow can validate version PR creation,
package publishing, root changelog generation, and GitHub Release creation under pnpm.
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
NODE_VERSION: '20'
PNPM_VERSION: '10.30.3'

jobs:
ci:
Expand All @@ -23,23 +24,27 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}

- name: Configure Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Install Dependencies
run: npm ci
run: pnpm install --frozen-lockfile

- name: Generate Prisma Client
# We can let turbo handle the caching for this
run: npx turbo run gen:prisma-all
run: pnpm turbo run gen:prisma-all

- name: Run Lint, Test, and Build
run: npx turbo run lint test:unit build
run: pnpm turbo run lint test:unit build
env:
# Env vars for build step
NODE_ENV: development
VITE_API_BASE_URL: ${{ vars.CI_API_BASE_URL }}
VITE_APP_ENV: ci
VITE_APP_ENV: ci
130 changes: 42 additions & 88 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,47 @@ on:
push:
branches:
- main
workflow_run:
workflows: ["Continuous Integration"]
types:
- completed
branches:
- main

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

env:
# Keep consistent with ci.yml
NODE_VERSION: '20'
HUSKY: 0 # Disable husky hooks
PNPM_VERSION: '10.30.3'
HUSKY: 0

jobs:
release:
# prevents this action from running on forks
if: github.repository == 'clinwise/release-scribe' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main'
permissions:
contents: write # to create release (changesets/action, git-cliff)
pull-requests: write # to create pull request (changesets/action)
contents: write
packages: write
pull-requests: write
name: Create Release or Publish
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
# We need to fetch history to generate changelog
fetch-depth: 0
# Need to push tag in hasChangesets == 'false' path
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check if the latest commit contains Changeset
id: check_latest_commit_changesets
# only run this check when workflow_run is triggered and head_branch is main
if: github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main'
run: |
# get the latest commit SHA of the main branch
# note: HEAD is already the latest main branch after checkout
MAIN_COMMIT_SHA=$(git rev-parse HEAD)
# get the previous commit SHA
PREVIOUS_COMMIT_SHA=$(git rev-parse HEAD~1)

# check if there are any changes in the .changeset directory (except README.md)
# if there are any non-README.md .md files changed, then it contains new changeset
if git diff --name-only "$PREVIOUS_COMMIT_SHA" "$MAIN_COMMIT_SHA" | grep -qE '\.changeset/[^/]+\.md$'; then
echo "latest_commit_has_changesets=true" >> "$GITHUB_OUTPUT"
else
echo "latest_commit_has_changesets=false" >> "$GITHUB_OUTPUT"
fi

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}

- name: Configure Node.JS
- name: Configure Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
registry-url: https://npm.pkg.github.com
scope: '@clinwise'

- name: Install Dependencies
run: npm install --ignore-scripts # Ignore husky post-install
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Install git-cliff
uses: kenji-miyake/setup-git-cliff@v2
Expand All @@ -75,74 +58,45 @@ jobs:

- name: Create Release PR or Prepare for Publish
id: changesets
# only run when:
# 1. direct push to main (usually after merging a PR with changesets)
# 2. workflow_run triggered, and the latest commit contains changesets
if: github.event_name == 'push' || (github.event_name == 'workflow_run' && steps.check_latest_commit_changesets.outputs.latest_commit_has_changesets == 'true')
uses: changesets/action@v1
with:
version: npm run changeset:version
version: pnpm run changeset:version
publish: pnpm run release:publish
title: "chore(release): version packages"
commit: "chore(release): version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publishing Process
id: publish
if: steps.changesets.outputs.hasChangesets == 'false'
if: steps.changesets.outputs.published == 'true'
run: |
# Only publish if NEXT-CHANGELOG-ENTRY.md exists and is not empty
RELEASE_VERSION=$(node -p "require('./package.json').version")
echo "release_version=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"

if [ -s NEXT-CHANGELOG-ENTRY.md ]; then
echo "NEXT-CHANGELOG-ENTRY.md detected, starting publishing process."

BUMPED_VERSION=$(git cliff --bumped-version)
if [ -z "$BUMPED_VERSION" ]; then
echo "git-cliff could not determine a new version number. No eligible conventional commits found."
# Even if no bumped_version, still need to clean log and push to avoid loop
# But we set released to false
> NEXT-CHANGELOG-ENTRY.md
git add NEXT-CHANGELOG-ENTRY.md
git commit -m "chore(release): clear changelog entry"
git push origin main
echo "released=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "BUMPED_VERSION=${BUMPED_VERSION}" >> "$GITHUB_ENV"

# Prepare release notes
cat NEXT-CHANGELOG-ENTRY.md >> RELEASE_NOTES.md

# Update main CHANGELOG.md
# This is a more robust method that adds new logs to the top of the file while preserving the original file
TEMP_CHANGELOG=$(mktemp)
cat RELEASE_NOTES.md CHANGELOG.md > "$TEMP_CHANGELOG"
mv "$TEMP_CHANGELOG" CHANGELOG.md

# Clean up NEXT-CHANGELOG-ENTRY.md
> NEXT-CHANGELOG-ENTRY.md

# Commit changes
git add CHANGELOG.md NEXT-CHANGELOG-ENTRY.md
git commit -m "chore(release): update changelog for ${BUMPED_VERSION}"

# Create and Push Tag
git tag -a "${BUMPED_VERSION}" -m "Release ${BUMPED_VERSION}"
git push origin main --follow-tags

# Set outputs for next step
echo "tag_name=${BUMPED_VERSION}" >> $GITHUB_OUTPUT
echo "release_body_path=RELEASE_NOTES.md" >> $GITHUB_OUTPUT
echo "released=true" >> $GITHUB_OUTPUT
cp NEXT-CHANGELOG-ENTRY.md RELEASE_NOTES.md
else
echo "NEXT-CHANGELOG-ENTRY.md not found or is empty, skipping release."
echo "released=false" >> $GITHUB_OUTPUT
pnpm exec git-cliff --unreleased --output RELEASE_NOTES.md --strip header --bump
fi

pnpm exec git-cliff --unreleased --bump --output CHANGELOG.md
: > NEXT-CHANGELOG-ENTRY.md

git add CHANGELOG.md NEXT-CHANGELOG-ENTRY.md
git commit -m "chore(release): update changelog for ${RELEASE_VERSION}"

git tag -a "${RELEASE_VERSION}" -m "Release ${RELEASE_VERSION}"
git push origin main --follow-tags

echo "release_body_path=RELEASE_NOTES.md" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
if: steps.publish.outputs.released == 'true'
if: steps.changesets.outputs.published == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.publish.outputs.tag_name }}
tag_name: ${{ steps.publish.outputs.release_version }}
body_path: ${{ steps.publish.outputs.release_body_path }}
repository: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
113 changes: 76 additions & 37 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,125 @@
## [0.2.4] - 2025-10-10
# Changelog

### 🐛 Bug Fixes
All notable changes to this project will be documented in this file.

## [unreleased]

### Features

- Migrate release automation workflow to pnpm



### Bug Fixes

- Fix duplicate version number headers in release notes
## 0.2.3 - 2025-07-31
## [0.2.3] - 2025-07-31

### 🚜 Refactor


### Refactor

- Try to optimize the speed of CI workflow
## 0.2.2 - 2025-07-29



### Documentation

- Update


## [0.2.2] - 2025-07-29

### 🐛 Bug Fixes
### Bug Fixes

- Attempt to fix the issue where the modification to NEXT-CHANGELOG-ENTRY.md in the version package pr is invalid

- Attempt to fix the issue where the modification to NEXT-CHANGELOG-ENTRY.md in the version package pr is invalid :)
- Avoid triggering changes within the version package PR itself :)
## 0.2.1 - 2025-07-28



### Documentation

- Update README


## [0.2.1] - 2025-07-28

### 🐛 Bug Fixes
### Bug Fixes

- Fix the issue where the commited log in NEXT-CHANGELOG-ENTRY is empty

### 🚜 Refactor


### Refactor

- Modify the version update logic of package.json in the project root directory in the changeset-version script

### 📚 Documentation


### Documentation

- Update README
## 0.2.0 - 2025-07-28


## [0.2.0] - 2025-07-28
## 0.1.1 - 2025-07-28

### Features

- Use changeset-version.sh to update package.json version



### Testing

- Try to use version script



### Chore

- Rename version script to changeset:version


## [0.1.1] - 2025-07-28

### 🧪 Testing
### Testing

- Test

### ⚙️ Miscellaneous Tasks

- *(release)* Version packages
## 0.1.0 - 2025-07-28
## [0.1.0] - 2025-07-28

### 🚀 Features
### Features

- *(api, web)* Update the .gitignore file to include the .turbo directory; add Node.js version and npm package manager information in package.json; refactor the workspace order; update scripts to use turbo for building, testing, and linting; add a turbo.json configuration file; add mock build and lint scripts in the package.json of the api and web applications.

- Changeset init

- *(api, web)* Add test file

- Add --bump to version script

- Re-add --bump to version script

### 🐛 Bug Fixes


### Bug Fixes

- Fix the issue where the changeset command cannot be executed correctly in 'Create Release PR or Prepare for Publish'

### 🚜 Refactor


### Refactor

- Generate the file "NEXT-CHANGELOG-ENTRY.md" in the "release.yml" file

### ⚙️ Miscellaneous Tasks

- *(release)* Version packages
- Add CHANGELOG.md
- *(release)* Version packages
- Typo
## [0.1.0] - 2025-07-28

### 🚀 Features
### Chore

- *(api, web)* Update the .gitignore file to include the .turbo directory; add Node.js version and npm package manager information in package.json; refactor the workspace order; update scripts to use turbo for building, testing, and linting; add a turbo.json configuration file; add mock build and lint scripts in the package.json of the api and web applications.
- Changeset init
- *(api, web)* Add test file
- Add --bump to version script
- Re-add --bump to version script
- Add CHANGELOG.md

### 🐛 Bug Fixes
- Typo

- Fix the issue where the changeset command cannot be executed correctly in 'Create Release PR or Prepare for Publish'

### 🚜 Refactor

- Generate the file "NEXT-CHANGELOG-ENTRY.md" in the "release.yml" file
Loading
Loading