Fix changeset workflow to create GitHub releases for private packages
The changeset workflow runs changeset publish after the "Version Packages" PR merges, but produces no tags or releases because all packages are private. The command only creates tags as a side effect of npm publishing.
Changes
.github/workflows/changeset.yaml
- Added step that runs when
published != 'true' && hasChangesets != 'true'(post Version Packages merge) - Script iterates all
package.jsonfiles with accompanyingCHANGELOG.md - Creates git tag
package-name@versionand GitHub release with extracted changelog content for any version lacking a tag
.changeset/README.md
- Documents custom tag/release creation for private packages
- Explains why standard
changeset publishis insufficient
Behavior
After Version Packages merge:
# For each versioned package without a tag:
tag_name="${pkg_name}@${pkg_version}"
git tag "$tag_name"
git push origin "$tag_name"
# Extract version-specific changelog
changelog=$(awk -v ver="## $pkg_version" '
$0 ~ ver {flag=1; next}
/^## / && flag {exit}
flag {print}
' CHANGELOG.md)
gh release create "$tag_name" --notes "$changelog_content"
Currently will create 7 releases on next Version Packages merge: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected].
Original prompt
the changeset setup is not working we are using other workflow for publishing, so it is delegated but changest should create the github release at least. Two option:
- the setups is not right and we need to rework it
- the setup needs adjustments and we should remediate
Run changesets/action@v1 setting git user /usr/bin/git config user.name "github-actions[bot]" /usr/bin/git config user.email "41898282+github-actions[bot]@users.noreply.github.com" setting GitHub credentials No changesets found. Attempting to publish any unpublished packages to npm No user .npmrc file found, creating one /usr/local/bin/yarn release yarn run v1.22.22 $ changeset publish 🦋 warn No unpublished projects to publish Done in 0.32s.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
⚠️ No Changeset found
Latest commit: 1ca4fb69825387433685968da9b8eca1dc598757
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
@copilot investigate is the code from the changeset GitHub action, I am sure it has come build in mechanism and the reason is does work is because our publish command need to have a set output that match the expectations.
Reading and analyzing the action's code is the best, worse case we can contribute I don't want to introduce to much divergence in our code
@copilot investigate is the code from the changeset GitHub action, I am sure it has come build in mechanism and the reason is does work is because our publish command need to have a set output that ma...
You were absolutely right! After investigating the changesets/action source code, I found the built-in mechanism.
The action detects packages to release by parsing "New tag:" output from changeset publish (see run.ts:99-127). For private packages, this only happens when privatePackages.tag: true is set in the config.
Solution: Added this to .changeset/config.json:
"privatePackages": {
"version": true,
"tag": true
}
Now changeset publish outputs "New tag:" for all 19 private packages, and the action will create GitHub releases automatically. No custom script needed!
Commit: 1ca4fb6