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
46 changes: 18 additions & 28 deletions .github/workflows/agent-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,17 @@ name: Release Agent

on:
push:
branches:
- main
workflow_dispatch:
tags:
- "agent-v*"

concurrency:
group: agent-release
cancel-in-progress: false

jobs:
check-package-version:
name: Check package version and detect an update
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
committed-version: ${{ steps.check-package-version.outputs.committed-version }}
published-version: ${{ steps.check-package-version.outputs.published-version }}
is-new-version: ${{ steps.check-package-version.outputs.is-new-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Check package version and detect an update
id: check-package-version
uses: PostHog/check-package-version@v2
with:
path: packages/agent

release:
name: Publish release if new version
name: Publish agent to npm
runs-on: ubuntu-latest
needs: check-package-version
if: needs.check-package-version.outputs.is-new-version == 'true'
permissions:
contents: read
id-token: write
Expand All @@ -56,6 +32,20 @@ jobs:
cache: "pnpm"
registry-url: https://registry.npmjs.org

- name: Extract version from tag
id: version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/agent-v}"
echo "Version: $TAG_VERSION"
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"

- name: Set version in package.json
env:
APP_VERSION: ${{ steps.version.outputs.version }}
run: |
jq --arg v "$APP_VERSION" '.version = $v' packages/agent/package.json > tmp.json && mv tmp.json packages/agent/package.json
echo "Set packages/agent/package.json version to $APP_VERSION"

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

Expand All @@ -76,7 +66,7 @@ jobs:

- name: Publish the package to npm registry
working-directory: packages/agent
run: pnpm publish --access public
run: pnpm publish --access public --no-git-checks
env:
NPM_CONFIG_PROVENANCE: true
NODE_AUTH_TOKEN: ''
68 changes: 68 additions & 0 deletions .github/workflows/agent-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Tag Agent Release

on:
push:
branches:
- main
paths:
- "packages/agent/**"
- ".github/workflows/agent-tag.yml"
- ".github/workflows/agent-release.yml"

concurrency:
group: agent-tag
cancel-in-progress: false

jobs:
tag:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Get app token
id: app-token
uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3
with:
app_id: ${{ secrets.GH_APP_ARRAY_RELEASER_APP_ID }}
private_key: ${{ secrets.GH_APP_ARRAY_RELEASER_PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

- name: Compute version and create tag
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
REPOSITORY: ${{ github.repository }}
run: |
# Find the latest agent base version tag (agent-vX.Y or agent-vX.Y.0 format)
LATEST_TAG=$(git tag --list 'agent-v[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^agent-v[0-9]+\.[0-9]+(\.0)?$' | head -1)

if [ -z "$LATEST_TAG" ]; then
echo "No agent version tag found. Create one with: git tag agent-v2.1 && git push origin agent-v2.1"
exit 1
fi

# Extract major.minor from tag
VERSION_PART=${LATEST_TAG#agent-v}
MAJOR=$(echo "$VERSION_PART" | cut -d. -f1)
MINOR=$(echo "$VERSION_PART" | cut -d. -f2)

# Count commits since the base tag
PATCH=$(git rev-list "$LATEST_TAG"..HEAD --count)

if [ "$PATCH" -eq 0 ]; then
echo "No commits since $LATEST_TAG. Nothing to release."
exit 0
fi

NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
TAG="agent-v$NEW_VERSION"
echo "Creating tag: $TAG (from base tag $LATEST_TAG + $PATCH commits)"

git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git tag -a "$TAG" -m "Agent release $TAG"
git push "https://x-access-token:${GH_TOKEN}@github.com/$REPOSITORY" "$TAG"
6 changes: 3 additions & 3 deletions .github/workflows/tag.yml → .github/workflows/twig-tag.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tag Release
name: Tag Twig Release

on:
push:
Expand All @@ -11,11 +11,11 @@ on:
- "pnpm-lock.yaml"
- "package.json"
- "turbo.json"
- ".github/workflows/tag.yml"
- ".github/workflows/twig-tag.yml"
- ".github/workflows/twig-release.yml"

concurrency:
group: tag
group: twig-tag
cancel-in-progress: false

jobs:
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@posthog/agent",
"version": "2.0.3",
"version": "0.0.0-dev",
"repository": "https://github.com/PostHog/twig",
"description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
"exports": {
Expand Down
Loading