Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9ad3816
validation-versioning and publish actions
DoRightt Nov 20, 2025
694206b
package file changes test
DoRightt Nov 20, 2025
872b547
revert
DoRightt Nov 20, 2025
5bd0d9f
base rules changes test
DoRightt Nov 20, 2025
38518ba
Test: worflow changes
DoRightt Nov 20, 2025
4a13bf8
revert
DoRightt Nov 20, 2025
4a02b84
Test: readme changes do not trigger action
DoRightt Nov 20, 2025
fa60cca
revert
DoRightt Nov 20, 2025
b49a1cf
Test: package version was not bumped
DoRightt Nov 20, 2025
854e610
validate-versioning logging changes
DoRightt Nov 20, 2025
c00339a
validate-versioning logs changes
DoRightt Nov 20, 2025
96e0990
Test: decrease version
DoRightt Nov 20, 2025
a4a4005
revert
DoRightt Nov 20, 2025
e748ea2
Test. valid package changes and version bumps
DoRightt Nov 20, 2025
2f7f5bc
Test: minor changes
DoRightt Nov 20, 2025
3edb037
Test: major changes
DoRightt Nov 20, 2025
18bd6a8
Test: top-level package-lock versiom doesnt match
DoRightt Nov 21, 2025
9e774f6
revert
DoRightt Nov 21, 2025
f76ad89
Test: bottom-lvl package-lock version doesnt match
DoRightt Nov 21, 2025
b1a2822
Test: package-lock both versions updated
DoRightt Nov 21, 2025
ed3744c
Test: changes without changelog entry
DoRightt Nov 21, 2025
f9a2dbb
Test: changelog entry without body
DoRightt Nov 21, 2025
c343b82
Test: changelog entry version doesnt match
DoRightt Nov 21, 2025
918b40f
Test: valid changelog
DoRightt Nov 21, 2025
af72bd2
Test: valid pr
DoRightt Nov 21, 2025
36b4980
Test. no changelog changes at all
DoRightt Nov 21, 2025
b757d9e
valid state
DoRightt Nov 21, 2025
a511c32
package name changes for publish actions test
DoRightt Nov 21, 2025
c3da784
another changes for publish test
DoRightt Nov 21, 2025
d335dad
changes for publish test
DoRightt Nov 21, 2025
d11ed0f
scripts changes
DoRightt Nov 21, 2025
32af321
change for real publish
DoRightt Nov 21, 2025
32351de
test publishing with error token
DoRightt Nov 21, 2025
55ebbc3
revert
DoRightt Nov 21, 2025
06c94e0
Change validate-versioning workflow
DoRightt Nov 25, 2025
5cf091f
Test: change base rules
DoRightt Nov 25, 2025
2455adb
return to version 1.0.0
DoRightt Nov 25, 2025
c882d1b
revert validate-versioning changes
DoRightt Nov 25, 2025
cf88c58
Test: change base rules without version bump in package.json
DoRightt Nov 25, 2025
063159d
revert
DoRightt Nov 25, 2025
e7b4f3f
validate-versioning update
DoRightt Nov 28, 2025
e1bc458
versioun update
DoRightt Nov 28, 2025
c09ac8d
Test: change rule
DoRightt Nov 28, 2025
9a55dc6
revert rule changes
DoRightt Nov 28, 2025
da52e73
change workflow
DoRightt Nov 28, 2025
4a85f38
npm to pnpm
DoRightt Nov 28, 2025
6ef9cf5
removed workflow branches field for tests
DoRightt Nov 28, 2025
af8b36d
Test: no version update
DoRightt Nov 28, 2025
e2daaf1
revert
DoRightt Nov 28, 2025
89951d4
package and gitignore changes
DoRightt Nov 28, 2025
0e43197
package changes
DoRightt Nov 28, 2025
aead3c3
version upd
DoRightt Dec 1, 2025
d2d5498
ignores upd + version
DoRightt Dec 1, 2025
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
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@ on:
push:
branches:
- main
pull_request: null
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
- uses: actions/checkout@v5

- uses: actions/setup-node@v5
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
node-version: "20"
version: latest

- run: npm ci
- name: Setup Node.js
- uses: actions/setup-node@v5
with:
node-version: '20'
cache: 'pnpm'

- run: npm test
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish Package

on:
push:
tags:
- 'packages/*/v*'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Extract package and version from tag
id: tag
run: |
TAG=${GITHUB_REF#refs/tags/}
# packages/ui/v1.0.1 -> package=ui, version=1.0.1
PACKAGE_PATH=$(echo $TAG | cut -d'/' -f1-2) # packages/ui
PACKAGE_NAME=$(echo $PACKAGE_PATH | cut -d'/' -f2) # ui
VERSION=$(echo $TAG | cut -d'/' -f3 | sed 's/^v//') # 1.0.1

echo "package=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "package_path=$PACKAGE_PATH" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Tag: $TAG -> Package: $PACKAGE_NAME, Version: $VERSION"

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build package
run: npm run build --workspace=eslint-config-sukhov-test-${{ steps.tag.outputs.package }}

- name: Verify version matches package.json
run: |
PACKAGE_VERSION=$(node -e "console.log(require('./${{ steps.tag.outputs.package_path }}/package.json').version)")
if [ "$PACKAGE_VERSION" != "${{ steps.tag.outputs.version }}" ]; then
echo "❌ ERROR: Tag version (${{ steps.tag.outputs.version }}) doesn't match package.json version ($PACKAGE_VERSION)"
exit 1
fi
echo "✅ Version matches: $PACKAGE_VERSION"

- name: Publish to npm
run: npm publish --dry-run --workspace=eslint-config-sukhov-test-${{ steps.tag.outputs.package }}
env:
NODE_AUTH_TOKEN: ${{ secrets.TEST_NPM_TOKEN }}
204 changes: 204 additions & 0 deletions .github/workflows/validate-versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: Validate Versioning and Changelog

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- 'packages/ui/**'

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
cache: 'pnpm'

- name: Install semver package
run: pnpm add semver

- name: Check for changes in package
id: check-changes
run: |
# Check for changes in package files (excluding dist, node_modules)
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep "^packages/ui/" | grep -v "^packages/ui/dist/" | grep -v "^packages/ui/node_modules/" || true)

if [ -n "$CHANGED_FILES" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Package files have been modified:"
echo "$CHANGED_FILES"
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No relevant package files modified (excluding dist, node_modules)"
fi

- name: Validate versioning and changelog
if: steps.check-changes.outputs.has_changes == 'true'
run: |
set -e
PACKAGE_DIR="packages/ui"

echo "::group::Version Validation"
echo "Starting validation for package: $PACKAGE_DIR"

# Get current version from package.json
CURRENT_VERSION=$(node -e "console.log(require('./$PACKAGE_DIR/package.json').version)")
echo "Current version in package.json: $CURRENT_VERSION"

# Get base version (from base branch)
git fetch origin ${{ github.base_ref }} --depth=1 || true
BASE_VERSION=$(git show origin/${{ github.base_ref }}:$PACKAGE_DIR/package.json 2>/dev/null | node -e "const fs=require('fs'); const data=fs.readFileSync(0,'utf-8'); console.log(JSON.parse(data).version)" || echo "0.0.0")
echo "Base version in package.json: $BASE_VERSION"

# Validate version format and check if version was increased (semantic versioning)
echo "Validating version format and increment..."
set +e
VERSION_CHECK=$(node -e "
const semver = require('semver');
const current = '$CURRENT_VERSION';
const base = '$BASE_VERSION';

// Validate current version format
if (!semver.valid(current)) {
console.error('INVALID_CURRENT');
process.exit(1);
}

// Validate base version format (if not 0.0.0)
if (base !== '0.0.0' && !semver.valid(base)) {
console.error('INVALID_BASE');
process.exit(1);
}

// Check if versions are the same
if (current === base) {
console.error('SAME_VERSION');
process.exit(1);
}

// Check if current version is greater than base version
if (!semver.gt(current, base)) {
console.error('VERSION_NOT_INCREASED');
process.exit(1);
}

// Calculate suggested versions
const patch = semver.inc(base, 'patch');
const minor = semver.inc(base, 'minor');
const major = semver.inc(base, 'major');

console.log('OK');
console.log('PATCH=' + patch);
console.log('MINOR=' + minor);
console.log('MAJOR=' + major);
" 2>&1)

VERSION_CHECK_EXIT=$?
set -e

echo "Full version check output:"
echo "$VERSION_CHECK"

VERSION_CHECK_OUTPUT=$(echo "$VERSION_CHECK" | head -1 | tr -d '\r\n')
echo "First line of output: '$VERSION_CHECK_OUTPUT'"
echo "Exit code: $VERSION_CHECK_EXIT"

if [ $VERSION_CHECK_EXIT -ne 0 ]; then
echo "::error file=$PACKAGE_DIR/package.json::Version validation failed"

if echo "$VERSION_CHECK" | grep -q "INVALID_CURRENT"; then
echo "::error::Current version '$CURRENT_VERSION' is not a valid semantic version!"
echo "Please use semantic versioning format (e.g., 1.0.0, 1.0.1, 1.1.0, 2.0.0)"
exit 1
elif echo "$VERSION_CHECK" | grep -q "INVALID_BASE"; then
echo "⚠️ WARNING: Base version '$BASE_VERSION' is not a valid semantic version"
echo "Assuming version bump is valid (first release or manual version)"
elif echo "$VERSION_CHECK" | grep -q "SAME_VERSION"; then
echo "::error file=$PACKAGE_DIR/package.json::Version was not bumped!"
echo "Current version: $CURRENT_VERSION"
echo "Base version: $BASE_VERSION"
echo "Please bump the version in packages/ui/package.json"
exit 1
elif echo "$VERSION_CHECK" | grep -q "VERSION_NOT_INCREASED"; then
PATCH_VER=$(echo "$VERSION_CHECK" | grep "PATCH=" | cut -d= -f2)
MINOR_VER=$(echo "$VERSION_CHECK" | grep "MINOR=" | cut -d= -f2)
MAJOR_VER=$(echo "$VERSION_CHECK" | grep "MAJOR=" | cut -d= -f2)
echo "::error file=$PACKAGE_DIR/package.json::Version must be greater than base version!"
echo "Current version: $CURRENT_VERSION"
echo "Base version: $BASE_VERSION"
echo "The new version must be higher according to semantic versioning rules."
echo "Suggested versions:"
echo " - Patch: $BASE_VERSION -> $PATCH_VER"
echo " - Minor: $BASE_VERSION -> $MINOR_VER"
echo " - Major: $BASE_VERSION -> $MAJOR_VER"
exit 1
else
echo "::error::Unknown version validation error"
echo "Exit code: $VERSION_CHECK_EXIT"
echo "Full output was:"
echo "$VERSION_CHECK"
exit 1
fi
else
echo "✅ Version was bumped from $BASE_VERSION to $CURRENT_VERSION (valid semver increment)"
fi
echo "::endgroup::"

echo "::group::Changelog Validation"
# Check if changelog has entry for this version
CHANGELOG_FILE="$PACKAGE_DIR/CHANGELOG.md"
echo "Checking changelog file: $CHANGELOG_FILE"
echo "Looking for version: $CURRENT_VERSION"

if ! grep -q "^## \\[$CURRENT_VERSION\\]" "$CHANGELOG_FILE"; then
echo "::error file=$CHANGELOG_FILE::Changelog entry for version $CURRENT_VERSION not found!"
echo "Please add a changelog entry in $CHANGELOG_FILE with the format:"
echo "## [$CURRENT_VERSION] - YYYY-MM-DD"
exit 1
fi

echo "✅ Changelog entry found for version $CURRENT_VERSION"

# Verify changelog entry is not empty (has content after the version header)
CHANGELOG_LINE=$(grep -n "^## \\[$CURRENT_VERSION\\]" "$CHANGELOG_FILE" | cut -d: -f1)
echo "Changelog entry found at line: $CHANGELOG_LINE"

# Check if there's content after the version header (skip empty entries)
NEXT_VERSION_LINE=$(tail -n +$((CHANGELOG_LINE + 1)) "$CHANGELOG_FILE" | grep -n "^## \\[" | head -1 | cut -d: -f1)
if [ -z "$NEXT_VERSION_LINE" ]; then
# This is the latest version, check if there's any content after the header
LINES_AFTER_HEADER=$(tail -n +$((CHANGELOG_LINE + 1)) "$CHANGELOG_FILE" | grep -v '^$' | head -1)
if [ -z "$LINES_AFTER_HEADER" ]; then
echo "::error file=$CHANGELOG_FILE::Changelog entry for version $CURRENT_VERSION is empty!"
echo "Please add at least one change entry (Added, Changed, Fixed, etc.)"
exit 1
fi
else
# Check if there's content between this version and the next
LINES_BETWEEN=$(sed -n "$((CHANGELOG_LINE + 1)),$((CHANGELOG_LINE + NEXT_VERSION_LINE - 1))p" "$CHANGELOG_FILE" | grep -v '^$' | head -1)
if [ -z "$LINES_BETWEEN" ]; then
echo "::error file=$CHANGELOG_FILE::Changelog entry for version $CURRENT_VERSION is empty!"
echo "Please add at least one change entry (Added, Changed, Fixed, etc.)"
exit 1
fi
fi

echo "✅ Changelog entry for version $CURRENT_VERSION has content"
echo "::endgroup::"

echo "::notice::All validations passed successfully!"

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
dist/
.npmrc
Loading