Skip to content

Commit a740ed4

Browse files
authored
Merge pull request #1 from plotday/initial-automated-release
Initial automated release
2 parents ce23ab2 + dce4f2f commit a740ed4

15 files changed

Lines changed: 1310 additions & 17 deletions

File tree

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3+
"changelog": ["@changesets/changelog-github", { "repo": "plotday/plot" }],
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": ["@plotday/agent-*"]
11+
}

.changeset/goofy-groups-switch.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@plotday/tool-outlook-calendar": patch
3+
"@plotday/tool-google-calendar": patch
4+
"@plotday/tool-google-contacts": patch
5+
"@plotday/sdk": patch
6+
---
7+
8+
Initial automated release setup

.changeset/shiny-wolves-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/sdk": minor
3+
---
4+
5+
Add README.md and AGENTS.md on "plot agent create"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Changeset Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check:
10+
name: Check for changeset
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v4
20+
with:
21+
version: 10.18.3
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Check if SDK or tools were modified
33+
id: check-changes
34+
run: |
35+
# Get list of changed files
36+
git fetch origin main
37+
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
38+
39+
# Check if SDK or tools directories were modified
40+
SDK_CHANGED=$(echo "$CHANGED_FILES" | grep -E '^sdk/' || true)
41+
TOOLS_CHANGED=$(echo "$CHANGED_FILES" | grep -E '^tools/' || true)
42+
43+
if [ -n "$SDK_CHANGED" ] || [ -n "$TOOLS_CHANGED" ]; then
44+
echo "needs-changeset=true" >> $GITHUB_OUTPUT
45+
echo "SDK or tools packages were modified"
46+
else
47+
echo "needs-changeset=false" >> $GITHUB_OUTPUT
48+
echo "No SDK or tools changes detected"
49+
fi
50+
51+
- name: Check for changesets
52+
if: steps.check-changes.outputs.needs-changeset == 'true'
53+
run: |
54+
# Check if there are any changeset files (excluding README.md and config.json)
55+
CHANGESET_COUNT=$(ls -1 .changeset/*.md 2>/dev/null | grep -v README.md | wc -l | tr -d ' ')
56+
57+
if [ "$CHANGESET_COUNT" -eq 0 ]; then
58+
echo "❌ Error: Changes detected in SDK or tools packages, but no changeset found."
59+
echo ""
60+
echo "Please add a changeset by running:"
61+
echo " pnpm changeset"
62+
echo ""
63+
echo "This helps maintain proper versioning and changelogs."
64+
exit 1
65+
else
66+
echo "✅ Changeset found (count: $CHANGESET_COUNT)"
67+
fi

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v4
22+
with:
23+
version: 10.18.3
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
cache: 'pnpm'
30+
31+
- name: Install dependencies
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Create Release Pull Request or Publish to npm
35+
id: changesets
36+
uses: changesets/action@v1
37+
with:
38+
version: pnpm version-packages
39+
publish: pnpm release
40+
commit: 'chore: version packages'
41+
title: 'chore: version packages'
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
46+
- name: Create GitHub Releases
47+
if: steps.changesets.outputs.published == 'true'
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
# Parse published packages and create releases for each
52+
echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -c '.[]' | while read -r package; do
53+
name=$(echo "$package" | jq -r '.name')
54+
version=$(echo "$package" | jq -r '.version')
55+
56+
# Determine package directory
57+
if [[ "$name" == "@plotday/sdk" ]]; then
58+
pkg_dir="sdk"
59+
elif [[ "$name" == @plotday/tool-* ]]; then
60+
tool_name="${name#@plotday/tool-}"
61+
pkg_dir="tools/$tool_name"
62+
else
63+
echo "Unknown package: $name"
64+
continue
65+
fi
66+
67+
# Create tag name (e.g., sdk@0.9.1 or tool-google-calendar@0.1.0)
68+
tag_name="${pkg_dir//\//@}@${version}"
69+
70+
# Extract changelog entry for this version
71+
changelog_file="$pkg_dir/CHANGELOG.md"
72+
if [ -f "$changelog_file" ]; then
73+
# Extract the section for this version from CHANGELOG
74+
release_notes=$(awk "/## ${version}/,/## [0-9]/" "$changelog_file" | sed '1d;$d' | sed '/^$/d')
75+
76+
if [ -z "$release_notes" ]; then
77+
release_notes="Release ${name}@${version}"
78+
fi
79+
else
80+
release_notes="Release ${name}@${version}"
81+
fi
82+
83+
# Create GitHub release
84+
echo "Creating release for $name@$version with tag $tag_name"
85+
gh release create "$tag_name" \
86+
--title "${name}@${version}" \
87+
--notes "$release_notes" \
88+
--verify-tag || echo "Release creation failed for $tag_name, may already exist"
89+
done
90+
91+
- name: Summary
92+
if: steps.changesets.outputs.published == 'true'
93+
run: |
94+
echo "### 🚀 Published Packages" >> $GITHUB_STEP_SUMMARY
95+
echo "" >> $GITHUB_STEP_SUMMARY
96+
echo "The following packages were published to npm:" >> $GITHUB_STEP_SUMMARY
97+
echo "" >> $GITHUB_STEP_SUMMARY
98+
echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | "- **\(.name)@\(.version)** ([GitHub Release](https://github.com/${{ github.repository }}/releases/tag/\(.name | gsub("@plotday/"; "") | gsub("/"; "@"))@\(.version)))"' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)