@@ -72,16 +72,30 @@ jobs:
7272 id : version
7373 run : echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
7474
75+ - name : Check if version is already published
76+ id : check_published
77+ run : |
78+ PACKAGE_NAME=$(node -p 'require("./package.json").name')
79+ VERSION="${{ steps.version.outputs.version }}"
80+ echo "Checking npm registry for ${PACKAGE_NAME}@${VERSION}..."
81+ if npm view "${PACKAGE_NAME}@${VERSION}" version 2>&1; then
82+ echo "Version ${VERSION} is already published to npm. Skipping publish."
83+ echo "already_published=true" >> "$GITHUB_OUTPUT"
84+ else
85+ echo "Version ${VERSION} is not yet published. Proceeding with publish."
86+ echo "already_published=false" >> "$GITHUB_OUTPUT"
87+ fi
88+
7589 - name : Publish to npm
76- if : ${{ !inputs.dry_run }}
90+ if : ${{ !inputs.dry_run && steps.check_published.outputs.already_published != 'true' }}
7791 run : NODE_AUTH_TOKEN="" npm publish
7892
7993 - name : Dry run publish
8094 if : ${{ inputs.dry_run }}
8195 run : NODE_AUTH_TOKEN="" npm publish public --dry-run
8296
8397 - name : Commit version bump and create PR
84- if : ${{ !inputs.dry_run }}
98+ if : ${{ !inputs.dry_run && steps.check_published.outputs.already_published != 'true' }}
8599 run : |
86100 cd ..
87101 git config user.name "github-actions[bot]"
@@ -101,15 +115,21 @@ jobs:
101115 - name : Summary
102116 run : |
103117 {
104- echo "## CLI Package Published 📦"
105- echo ""
106- echo "- **Version:** v${{ steps.version.outputs.version }}"
107- echo "- **Bump:** ${{ inputs.version_bump }}"
108- echo "- **Dry run:** ${{ inputs.dry_run }}"
109- echo ""
110- if [ "${{ inputs.dry_run }}" = "false" ]; then
111- echo "Install with: \`npx @rajbos/ai-engineering-fluency\`"
118+ if [ "${{ steps.check_published.outputs.already_published }}" = "true" ]; then
119+ echo "## CLI Package Publish Skipped ⏭️"
120+ echo ""
121+ echo "Version **v${{ steps.version.outputs.version }}** is already published to npm."
122+ else
123+ echo "## CLI Package Published 📦"
124+ echo ""
125+ echo "- **Version:** v${{ steps.version.outputs.version }}"
126+ echo "- **Bump:** ${{ inputs.version_bump }}"
127+ echo "- **Dry run:** ${{ inputs.dry_run }}"
112128 echo ""
113- echo "A PR has been opened to merge the version bump back to main."
129+ if [ "${{ inputs.dry_run }}" = "false" ]; then
130+ echo "Install with: \`npx @rajbos/ai-engineering-fluency\`"
131+ echo ""
132+ echo "A PR has been opened to merge the version bump back to main."
133+ fi
114134 fi
115135 } >> "$GITHUB_STEP_SUMMARY"
0 commit comments