Skip to content

Commit 6b3a3c3

Browse files
authored
fix: Fix CI/CD pipeline trying to double release on commits to main (#532)
1 parent 5b55a21 commit 6b3a3c3

File tree

3 files changed

+80
-57
lines changed

3 files changed

+80
-57
lines changed

.github/workflows/agent-release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- "v*"
97
workflow_dispatch:
108

119
concurrency:

.github/workflows/array-release.yml

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@ name: Release Array
22

33
on:
44
push:
5-
branches:
6-
- main
7-
paths:
8-
- "apps/array/**"
9-
- "packages/agent/**"
10-
- "packages/electron-trpc/**"
11-
- "pnpm-lock.yaml"
12-
- "package.json"
13-
- "turbo.json"
14-
- ".github/workflows/array-release.yml"
155
tags:
166
- "v*"
177

@@ -57,48 +47,17 @@ jobs:
5747
node-version: 22
5848
cache: "pnpm"
5949

60-
- name: Compute version from git tags
50+
- name: Extract version from tag
6151
id: version
6252
run: |
63-
# Find the latest minor version tag (vX.Y format - exactly 2 parts)
64-
# These are manually created to mark new minor releases
65-
# Release tags (vX.Y.Z) are ignored for base version calculation
66-
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+$' | head -1)
67-
68-
# Fall back to vX.Y.0 format if no vX.Y tags exist (backward compat)
69-
if [ -z "$LATEST_TAG" ]; then
70-
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*.0' --sort=-v:refname | head -1)
71-
fi
72-
73-
if [ -z "$LATEST_TAG" ]; then
74-
echo "No version tag found. Create one with: git tag v0.15 && git push origin v0.15"
75-
exit 1
76-
fi
77-
78-
# Extract major.minor from tag
79-
VERSION_PART=${LATEST_TAG#v}
80-
MAJOR=$(echo "$VERSION_PART" | cut -d. -f1)
81-
MINOR=$(echo "$VERSION_PART" | cut -d. -f2)
82-
83-
# Count commits since the base tag
84-
PATCH=$(git rev-list "$LATEST_TAG"..HEAD --count)
85-
86-
if [ "$PATCH" -eq 0 ]; then
87-
echo "No commits since $LATEST_TAG. Nothing to release."
88-
exit 1
89-
fi
90-
91-
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
92-
echo "Version: $NEW_VERSION (from base tag $LATEST_TAG + $PATCH commits)"
93-
94-
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
95-
echo "base_tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
53+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
54+
echo "Version: $TAG_VERSION"
55+
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
9656
9757
- name: Set version in package.json
9858
env:
9959
APP_VERSION: ${{ steps.version.outputs.version }}
10060
run: |
101-
# Update package.json for the build (not committed)
10261
jq --arg v "$APP_VERSION" '.version = $v' apps/array/package.json > tmp.json && mv tmp.json apps/array/package.json
10362
echo "Set apps/array/package.json version to $APP_VERSION"
10463
@@ -132,16 +91,6 @@ jobs:
13291
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN"
13392
rm "$RUNNER_TEMP/certificate.p12"
13493
135-
- name: Create tag
136-
env:
137-
APP_VERSION: ${{ steps.version.outputs.version }}
138-
GH_TOKEN: ${{ steps.app-token.outputs.token }}
139-
REPOSITORY: ${{ github.repository }}
140-
run: |
141-
TAG="v$APP_VERSION"
142-
git tag -a "$TAG" -m "Release $TAG"
143-
git push "https://x-access-token:${GH_TOKEN}@github.com/$REPOSITORY" "$TAG"
144-
14594
- name: Build native modules
14695
run: pnpm --filter array run build-native
14796

.github/workflows/tag.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Tag Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "apps/array/**"
9+
- "packages/agent/**"
10+
- "packages/electron-trpc/**"
11+
- "pnpm-lock.yaml"
12+
- "package.json"
13+
- "turbo.json"
14+
- ".github/workflows/tag.yml"
15+
- ".github/workflows/array-release.yml"
16+
17+
concurrency:
18+
group: tag
19+
cancel-in-progress: false
20+
21+
jobs:
22+
tag:
23+
permissions:
24+
contents: write
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Get app token
28+
id: app-token
29+
uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3
30+
with:
31+
app_id: ${{ secrets.GH_APP_ARRAY_RELEASER_APP_ID }}
32+
private_key: ${{ secrets.GH_APP_ARRAY_RELEASER_PRIVATE_KEY }}
33+
34+
- name: Checkout
35+
uses: actions/checkout@v6
36+
with:
37+
fetch-depth: 0
38+
token: ${{ steps.app-token.outputs.token }}
39+
40+
- name: Compute version and create tag
41+
env:
42+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
43+
REPOSITORY: ${{ github.repository }}
44+
run: |
45+
# Find the latest minor version tag (vX.Y format - exactly 2 parts)
46+
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+$' | head -1)
47+
48+
# Fall back to vX.Y.0 format if no vX.Y tags exist (backward compat)
49+
if [ -z "$LATEST_TAG" ]; then
50+
LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*.0' --sort=-v:refname | head -1)
51+
fi
52+
53+
if [ -z "$LATEST_TAG" ]; then
54+
echo "No version tag found. Create one with: git tag v0.15 && git push origin v0.15"
55+
exit 1
56+
fi
57+
58+
# Extract major.minor from tag
59+
VERSION_PART=${LATEST_TAG#v}
60+
MAJOR=$(echo "$VERSION_PART" | cut -d. -f1)
61+
MINOR=$(echo "$VERSION_PART" | cut -d. -f2)
62+
63+
# Count commits since the base tag
64+
PATCH=$(git rev-list "$LATEST_TAG"..HEAD --count)
65+
66+
if [ "$PATCH" -eq 0 ]; then
67+
echo "No commits since $LATEST_TAG. Nothing to release."
68+
exit 0
69+
fi
70+
71+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
72+
TAG="v$NEW_VERSION"
73+
echo "Creating tag: $TAG (from base tag $LATEST_TAG + $PATCH commits)"
74+
75+
git tag -a "$TAG" -m "Release $TAG"
76+
git push "https://x-access-token:${GH_TOKEN}@github.com/$REPOSITORY" "$TAG"

0 commit comments

Comments
 (0)