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
42 changes: 37 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,51 @@ jobs:
with:
fetch-depth: 0

- name: Validate tag exists on this push
- name: Validate version tag and package.json
run: |
TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "")
# Try to find a version tag on HEAD or recent commits
TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || git tag --list --sort=-version:refname --merged HEAD 'v*.*.*' | head -1 || echo "")

Comment on lines +25 to +27
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow no longer guarantees the HEAD commit is tagged: it falls back to the most recent merged v*.*.* tag, so a push to master without a new tag can still pass validation and attempt to publish again (likely failing with “version already exists” or, worse, publishing from an untagged commit). Consider requiring an exact tag on HEAD and/or triggering the workflow on push to tags: ['v*.*.*'] so the published commit is always the tagged one.

Copilot uses AI. Check for mistakes.
if [[ -z "$TAG" ]]; then
echo "❌ No tag found on HEAD. This push did not include a version tag."
echo "To publish, merge to master with a tag: git tag v1.0.0 && git push origin master --tags"
echo "❌ ERROR: No version tag found!"
echo ""
echo "This typically happens when:"
echo " 1. You forgot to run 'npm version patch|minor|major' on develop"
echo " 2. You didn't push tags when merging develop→master"
echo " 3. PR merge didn't include the tag from develop"
echo ""
echo "📋 Correct workflow:"
echo " 1. On develop: npm version patch (or minor/major)"
echo " 2. On develop: git push origin develop --tags"
echo " 3. Create PR develop→master and merge"
echo " 4. Workflow automatically triggers on master with the tag"
Comment on lines +31 to +40
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failure message recommends npm version patch|minor|major, but this repo is already set up for Changesets (.changeset/ directory and changeset/version-packages scripts in package.json). This guidance is likely to confuse the intended release flow—either update the message to the actual Changesets-based commands, or remove/disable Changesets if it’s not the chosen approach.

Copilot uses AI. Check for mistakes.
echo ""
exit 1
fi

# Validate tag format
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid tag format: $TAG. Expected: v*.*.*"
echo "❌ ERROR: Invalid tag format: '$TAG'"
echo "Expected format: v*.*.* (e.g., v1.0.0, v0.2.3)"
exit 1
fi

# Extract version from tag
TAG_VERSION="${TAG#v}" # Remove 'v' prefix
PKG_VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing package.json with grep | sed is brittle (formatting changes, comments, or additional "version" fields can break it). Prefer a structured read (e.g., node -e with JSON.parse, npm pkg get version, or jq -r .version) to make the version check reliable.

Suggested change
PKG_VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
PKG_VERSION=$(node -p "require('./package.json').version")

Copilot uses AI. Check for mistakes.

# Verify package.json version matches tag
if [[ "$TAG_VERSION" != "$PKG_VERSION" ]]; then
echo "❌ ERROR: Version mismatch!"
echo " Tag version: $TAG_VERSION"
echo " package.json: $PKG_VERSION"
echo ""
echo "Fix: Make sure you ran 'npm version' before pushing"
exit 1
fi

echo "✅ Valid tag found: $TAG"
echo "✅ Version matches package.json: $PKG_VERSION"
echo "TAG_VERSION=$TAG" >> $GITHUB_ENV
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TAG_VERSION is computed without the v prefix, but the value exported to $GITHUB_ENV is $TAG (still includes the v prefix). This makes the env var name misleading and can break later steps that expect a pure semver (e.g., 0.0.1). Export the actual TAG_VERSION value (or rename the variable to TAG).

Suggested change
echo "TAG_VERSION=$TAG" >> $GITHUB_ENV
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV

Copilot uses AI. Check for mistakes.

- name: Setup Node.js
Expand Down
273 changes: 8 additions & 265 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ciscode/notification-kit",
"version": "0.0.0",
"version": "0.0.1",
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR directly bumps package.json version, but the repository is configured for Changesets-based versioning (see changeset/version-packages scripts and .changeset/ config). If Changesets is the intended release mechanism, the version should typically be updated via changeset version (driven by changeset files) rather than manual edits, to avoid divergence between changesets and published versions.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description is still the default template (no Summary/Why/Notes filled in), which makes it hard to validate intent and release impact (especially around versioning/publishing). Please add a short summary of what’s being released and why, and call out the intended versioning approach (Changesets vs npm version).

Copilot uses AI. Check for mistakes.
"description": "A notification library for NestJS applications.",
"author": "CisCode",
"publishConfig": {
Expand Down
Loading