Skip to content

Commit 3902732

Browse files
committed
ci(event-store-kysely): fix version
1 parent 73961e1 commit 3902732

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ jobs:
8989
- name: Build package
9090
run: npm run build
9191

92+
- name: Fix npm dist-tag (if needed)
93+
if: matrix.package == 'emmett-event-store-kysely'
94+
env:
95+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
96+
run: |
97+
CURRENT_LATEST=$(npm dist-tag ls @wataruoguchi/emmett-event-store-kysely 2>/dev/null | grep "latest:" | awk '{print $2}' || echo "1.0.2")
98+
if [ "$CURRENT_LATEST" != "2.1.0" ] && npm view @wataruoguchi/emmett-event-store-kysely@2.1.0 version > /dev/null 2>&1; then
99+
echo "Fixing dist-tag from $CURRENT_LATEST to 2.1.0"
100+
npm dist-tag add @wataruoguchi/emmett-event-store-kysely@2.1.0 latest
101+
else
102+
echo "Dist-tag is already correct or version 2.1.0 not found"
103+
fi
104+
92105
- name: Release
93106
env:
94107
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Scripts
2+
3+
Utility scripts for maintaining the monorepo.
4+
5+
## fix-npm-dist-tag.sh
6+
7+
Fixes npm dist-tags for packages when they get out of sync.
8+
9+
### Usage
10+
11+
```bash
12+
./scripts/fix-npm-dist-tag.sh <package-name> <target-version>
13+
```
14+
15+
### Example
16+
17+
```bash
18+
# Fix the dist-tag for emmett-event-store-kysely to point to version 2.1.0
19+
./scripts/fix-npm-dist-tag.sh @wataruoguchi/emmett-event-store-kysely 2.1.0
20+
```
21+
22+
### When to use
23+
24+
This script is useful when:
25+
- The npm `latest` dist-tag is pointing to an old version
26+
- After manually publishing versions that bypassed semantic-release
27+
- When recovering from version sync issues
28+
29+
### Note
30+
31+
Requires npm authentication. Make sure you're logged in with `npm login` or have `NPM_TOKEN` set in your environment.

scripts/fix-npm-dist-tag.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Script to fix npm dist-tag for packages
3+
# Usage: ./scripts/fix-npm-dist-tag.sh <package-name> <target-version>
4+
5+
set -e
6+
7+
PACKAGE_NAME="$1"
8+
TARGET_VERSION="$2"
9+
10+
if [ -z "$PACKAGE_NAME" ] || [ -z "$TARGET_VERSION" ]; then
11+
echo "Usage: $0 <package-name> <target-version>"
12+
echo "Example: $0 @wataruoguchi/emmett-event-store-kysely 2.1.0"
13+
exit 1
14+
fi
15+
16+
echo "Checking current dist-tag for $PACKAGE_NAME..."
17+
CURRENT_LATEST=$(npm dist-tag ls "$PACKAGE_NAME" 2>/dev/null | grep "latest:" | awk '{print $2}' || echo "")
18+
19+
if [ -z "$CURRENT_LATEST" ]; then
20+
echo "Error: Could not fetch current dist-tag for $PACKAGE_NAME"
21+
exit 1
22+
fi
23+
24+
echo "Current 'latest' dist-tag: $CURRENT_LATEST"
25+
echo "Target version: $TARGET_VERSION"
26+
27+
# Check if target version exists on npm
28+
if ! npm view "$PACKAGE_NAME@$TARGET_VERSION" version > /dev/null 2>&1; then
29+
echo "Error: Version $TARGET_VERSION does not exist on npm for $PACKAGE_NAME"
30+
exit 1
31+
fi
32+
33+
# Compare versions
34+
if [ "$CURRENT_LATEST" = "$TARGET_VERSION" ]; then
35+
echo "Dist-tag is already set to $TARGET_VERSION. No action needed."
36+
exit 0
37+
fi
38+
39+
# Check if target version is higher
40+
CURRENT_NUM=$(echo "$CURRENT_LATEST" | sed 's/[^0-9]//g')
41+
TARGET_NUM=$(echo "$TARGET_VERSION" | sed 's/[^0-9]//g')
42+
43+
if [ "$TARGET_NUM" -lt "$CURRENT_NUM" ] 2>/dev/null; then
44+
echo "Warning: Target version $TARGET_VERSION appears to be older than current $CURRENT_LATEST"
45+
read -p "Do you want to continue? (y/N) " -n 1 -r
46+
echo
47+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
48+
exit 1
49+
fi
50+
fi
51+
52+
echo "Updating dist-tag 'latest' to $TARGET_VERSION..."
53+
npm dist-tag add "$PACKAGE_NAME@$TARGET_VERSION" latest
54+
55+
echo "✓ Successfully updated dist-tag 'latest' to $TARGET_VERSION for $PACKAGE_NAME"

0 commit comments

Comments
 (0)