@@ -49,24 +49,45 @@ jobs:
4949 node-version : 22
5050 cache : " pnpm"
5151
52- - name : Bump minor version
52+ - name : Compute version from git tags
5353 id : version
5454 run : |
55- CURRENT_VERSION=$(jq -r .version apps/array/package.json)
56- MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1)
57- MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2)
58- NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
59- echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION"
55+ # Find the latest minor version tag (vX.Y format - exactly 2 parts)
56+ # These are manually created to mark new minor releases
57+ # Release tags (vX.Y.Z) are ignored for base version calculation
58+ LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+$' | head -1)
59+
60+ # Fall back to vX.Y.0 format if no vX.Y tags exist (backward compat)
61+ if [ -z "$LATEST_TAG" ]; then
62+ LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*.0' --sort=-v:refname | head -1)
63+ fi
64+
65+ if [ -z "$LATEST_TAG" ]; then
66+ echo "No version tag found. Create one with: git tag v0.15 && git push origin v0.15"
67+ exit 1
68+ fi
69+
70+ # Extract major.minor from tag
71+ VERSION_PART=${LATEST_TAG#v}
72+ MAJOR=$(echo "$VERSION_PART" | cut -d. -f1)
73+ MINOR=$(echo "$VERSION_PART" | cut -d. -f2)
6074
61- jq --arg v "$NEW_VERSION" '.version = $v' apps/array/package.json > tmp.json && mv tmp.json apps/array/package.json
75+ # Count commits since the base tag
76+ PATCH=$(git rev-list "$LATEST_TAG"..HEAD --count)
6277
63- git config user.name "posthog-bot"
64- git config user.email "[email protected] " 65- git add apps/array/package.json
66- git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
67- git push
78+ NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
79+ echo "Version: $NEW_VERSION (from base tag $LATEST_TAG + $PATCH commits)"
6880
6981 echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
82+ echo "base_tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
83+
84+ - name : Set version in package.json
85+ env :
86+ APP_VERSION : ${{ steps.version.outputs.version }}
87+ run : |
88+ # Update package.json for the build (not committed)
89+ jq --arg v "$APP_VERSION" '.version = $v' apps/array/package.json > tmp.json && mv tmp.json apps/array/package.json
90+ echo "Set apps/array/package.json version to $APP_VERSION"
7091
7192 - name : Install dependencies
7293 run : pnpm install --frozen-lockfile
0 commit comments