Skip to content

Commit d03d979

Browse files
author
Disturbing
committed
feat: setup proper direct-publish changesets workflow
1 parent 74148a9 commit d03d979

File tree

1 file changed

+49
-54
lines changed

1 file changed

+49
-54
lines changed

.github/workflows/release.yml

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -46,65 +46,66 @@ jobs:
4646
git config --global user.name "github-actions[bot]"
4747
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
4848
49+
- name: Build packages
50+
run: pnpm build
51+
52+
- name: Run tests
53+
run: pnpm test
54+
55+
- name: Check for changesets
56+
id: changesets
57+
run: |
58+
if [ -f .changeset/*.md ]; then
59+
echo "has_changesets=true" >> $GITHUB_OUTPUT
60+
echo "Changesets found, proceeding with release"
61+
else
62+
echo "has_changesets=false" >> $GITHUB_OUTPUT
63+
echo "No changesets found, skipping release"
64+
fi
65+
4966
- name: Version and Publish
50-
id: publish
67+
if: steps.changesets.outputs.has_changesets == 'true'
5168
run: |
5269
# Apply changesets (update version numbers)
5370
pnpm changeset version
54-
71+
72+
# Check if any versions were actually changed
73+
if git diff --quiet; then
74+
echo "No version changes to commit"
75+
exit 0
76+
fi
77+
5578
# Extract versions for release notes
5679
MCP_VERSION=$(node -p "require('./packages/mcp/package.json').version")
5780
TEST_UTILS_VERSION=$(node -p "require('./packages/test-utils/package.json').version")
5881
AGENT_VERSION=$(node -p "require('./packages/agent/package.json').version")
5982
CLI_VERSION=$(node -p "require('./packages/cli/package.json').version")
60-
echo "MCP_VERSION=${MCP_VERSION}" >> $GITHUB_OUTPUT
61-
echo "TEST_UTILS_VERSION=${TEST_UTILS_VERSION}" >> $GITHUB_OUTPUT
62-
echo "AGENT_VERSION=${AGENT_VERSION}" >> $GITHUB_OUTPUT
63-
echo "CLI_VERSION=${CLI_VERSION}" >> $GITHUB_OUTPUT
64-
echo "RELEASE_TAG=v${MCP_VERSION}" >> $GITHUB_OUTPUT
83+
84+
echo "MCP_VERSION=${MCP_VERSION}" >> $GITHUB_ENV
85+
echo "TEST_UTILS_VERSION=${TEST_UTILS_VERSION}" >> $GITHUB_ENV
86+
echo "AGENT_VERSION=${AGENT_VERSION}" >> $GITHUB_ENV
87+
echo "CLI_VERSION=${CLI_VERSION}" >> $GITHUB_ENV
88+
echo "RELEASE_TAG=v${MCP_VERSION}" >> $GITHUB_ENV
6589
6690
# Commit the version updates
6791
git add .
68-
git commit -m "chore(release): version packages" || echo "No changes to commit"
92+
git commit -m "chore(release): version packages"
6993
70-
# Build once more to ensure latest versions are included
94+
# Build again with updated versions
7195
pnpm build
7296
73-
# Run tests
74-
pnpm test
75-
76-
# Manually publish each package with npm
77-
echo "Publishing packages directly with npm..."
78-
79-
# Publish test-utils
80-
cd packages/test-utils
81-
npm publish --access public || echo "Failed to publish test-utils, may already exist"
97+
# Publish packages
98+
pnpm changeset publish
8299
83-
# Publish mcp
84-
cd ../mcp
85-
npm publish --access public || echo "Failed to publish mcp, may already exist"
86-
87-
# Publish agent
88-
cd ../agent
89-
npm publish --access public || echo "Failed to publish agent, may already exist"
90-
91-
# Publish CLI
92-
cd ../cli
93-
npm publish --access public || echo "Failed to publish cli, may already exist"
94-
95-
cd ../..
96-
97-
# Push the version updates and tags
98-
git push origin main
99-
100-
# Create and push a version tag
100+
# Push the version updates and create tag
101101
git tag -a "v${MCP_VERSION}" -m "Release v${MCP_VERSION}"
102-
git push --tags
102+
git push origin main --tags
103103
env:
104104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105105
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
106106

107107
- name: Create GitHub Release
108+
if: steps.changesets.outputs.has_changesets == 'true' && env.RELEASE_TAG != ''
108109
uses: actions/github-script@v7
109110
with:
110111
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -120,33 +121,27 @@ jobs:
120121
121122
// Create a nice markdown body
122123
const body = `
123-
## Packages
124+
## Packages
124125

125-
- @null-shot/mcp: ${MCP_VERSION}
126-
- @null-shot/test-utils: ${TEST_UTILS_VERSION}
127-
- @null-shot/agent: ${AGENT_VERSION}
128-
- @null-shot/cli: ${CLI_VERSION}
126+
- @nullshot/mcp: ${MCP_VERSION}
127+
- @nullshot/test-utils: ${TEST_UTILS_VERSION}
128+
- @nullshot/agent: ${AGENT_VERSION}
129+
- @nullshot/cli: ${CLI_VERSION}
129130

130-
## Recent Changes
131+
## Recent Changes
131132

132-
${commits.slice(0, 5).map(commit => (
133-
`- ${commit.commit.message} (${commit.sha.substring(0, 7)})`
134-
)).join('\n')}
133+
${commits.slice(0, 5).map(commit => (
134+
\`- \${commit.commit.message} (\${commit.sha.substring(0, 7)})\`
135+
)).join('\\n')}
135136
`;
136137
137138
// Create the release
138139
await github.rest.repos.createRelease({
139140
owner: context.repo.owner,
140141
repo: context.repo.repo,
141142
tag_name: RELEASE_TAG,
142-
name: `Release ${RELEASE_TAG}`,
143+
name: \`Release \${RELEASE_TAG}\`,
143144
body: body,
144145
draft: false,
145146
prerelease: false
146-
});
147-
env:
148-
RELEASE_TAG: ${{ steps.publish.outputs.RELEASE_TAG }}
149-
MCP_VERSION: ${{ steps.publish.outputs.MCP_VERSION }}
150-
TEST_UTILS_VERSION: ${{ steps.publish.outputs.TEST_UTILS_VERSION }}
151-
AGENT_VERSION: ${{ steps.publish.outputs.AGENT_VERSION }}
152-
CLI_VERSION: ${{ steps.publish.outputs.CLI_VERSION }}
147+
});

0 commit comments

Comments
 (0)