Skip to content
Merged
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
85 changes: 74 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ on:
- "**.md"
- ".github/CODEOWNERS"
- ".github/ISSUE_TEMPLATE/**"
workflow_dispatch:
inputs:
ref:
description: "The ref (branch, tag, or SHA) to checkout and release from"
required: true
type: string
tag:
description: "The npm dist-tag for the prerelease (e.g., 'v4-prerelease')"
required: true
type: string
default: "v4-prerelease"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -23,46 +34,46 @@ jobs:
packages: write
pull-requests: write
id-token: write
if: github.repository == 'triggerdotdev/trigger.dev'
if: github.repository == 'triggerdotdev/trigger.dev' && github.event_name != 'workflow_dispatch'
outputs:
published: ${{ steps.changesets.outputs.published }}
published_packages: ${{ steps.changesets.outputs.publishedPackages }}
published_package_version: ${{ steps.get_version.outputs.package_version }}
steps:
- name: ⬇️ Checkout repo
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Setup node
- name: Setup node
uses: buildjet/setup-node@v4
with:
node-version: 20.19.0
cache: "pnpm"

- name: 📥 Download deps
- name: Download deps
run: pnpm install --frozen-lockfile

- name: 📀 Generate Prisma Client
- name: Generate Prisma Client
run: pnpm run generate

- name: 🏗️ Build
- name: Build
run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev"

- name: 🔎 Type check
- name: Type check
run: pnpm run typecheck --filter "@trigger.dev/*" --filter "trigger.dev"

# This action has two responsibilities. The first time the workflow runs
# (initial push to the `main` branch) it will create a new branch and
# then open a PR with the related changes for the new version. After the
# PR is merged, the workflow will run again and this action will build +
# publish to npm.
- name: 🚀 PR / Publish
- name: Publish
if: ${{ !env.ACT }}
id: changesets
uses: changesets/action@v1
Expand All @@ -75,15 +86,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 📦 Get package version
- name: Get package version
if: steps.changesets.outputs.published == 'true'
id: get_version
run: |
package_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0].version')
echo "package_version=${package_version}" >> "$GITHUB_OUTPUT"

# this triggers the publish workflow for the docker images
- name: 🏷️ Create and push docker tag
- name: Create and push docker tag
if: steps.changesets.outputs.published == 'true'
run: |
set -e
Expand Down Expand Up @@ -141,3 +152,55 @@ jobs:
git commit -m "chore: update lockfile for release"
git push origin changeset-release/main
fi

prerelease:
name: 🚀 Prerelease
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
if: github.repository == 'triggerdotdev/trigger.dev' && github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.ref }}

- name: Validate ref is on main
run: |
if ! git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main; then
echo "Error: ref must be an ancestor of main (i.e., already merged)"
exit 1
fi
Comment on lines +170 to +175
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

actions/checkout@v4 fetch-depth origin/main remote tracking branch

💡 Result:

Short answer: use actions/checkout@v4 with fetch-depth: 0 (or a depth that includes the commit you need) and then explicitly fetch and set the remote-tracking branch for origin/main. Example:

  • uses: actions/checkout@v4
    with:
    fetch-depth: 0
    ref: refs/heads/${{ github.ref_name }} # optional: explicit ref

  • run: |

    ensure origin/main exists as a remote-tracking ref

    git fetch origin main:refs/remotes/origin/main --no-tags

    (optional) create local branch and set upstream to origin/main

    git checkout -B main origin/main
    git branch --set-upstream-to=origin/main main

Notes:

  • actions/checkout defaults to a single-commit shallow fetch; set fetch-depth: 0 to fetch full history and tags. [1]
  • There are known problems (Git 2.50 / runner changes) where origin/HEAD may not be created automatically; the explicit git fetch above is a reliable workaround. [2]

Sources:
[1] actions/checkout README (v4) — checkout docs.
[2] GitHub issues/blog reports on origin/HEAD missing after Git 2.50 / runner updates.


🏁 Script executed:

#!/bin/bash
# Better test: Verify git merge-base behavior in realistic scenarios

cd /tmp/git-test-validation
rm -rf /tmp/git-test-validation

# Setup: Create a repo with realistic structure
mkdir -p /tmp/git-test-validation
cd /tmp/git-test-validation

# Initialize local repo
git init local-repo
cd local-repo
git config user.email "test@test.com"
git config user.name "Test"

# Create initial commit
echo "v1" > file.txt
git add file.txt
git commit -m "initial commit"

# Create main branch explicitly
git branch -M main

# Setup a "remote" (in same filesystem to simulate)
cd ..
git clone --bare local-repo origin-repo.git

# Now work in local repo with origin configured
cd local-repo
git remote add origin ../origin-repo.git
git push -u origin main

# Test 1: HEAD on main (typical case after checkout of main branch)
echo "=== Test 1: HEAD on main ==="
REF=$(git rev-parse HEAD)
if git merge-base --is-ancestor "$REF" origin/main 2>&1; then
  echo "✓ PASS: SHA on main validated"
else
  echo "✗ FAIL: SHA on main rejected"
fi

# Test 2: Branch name as ref
echo "=== Test 2: Branch name as ref ==="
git checkout -b feature-branch
echo "v2" > file.txt
git add file.txt
git commit -m "feature work"
if git merge-base --is-ancestor feature-branch origin/main 2>&1; then
  echo "✓ PASS: Non-pushed local branch validated (unexpected - it's a descendant)"
else
  echo "✗ FAIL: Non-pushed local branch rejected"
fi

# Test 3: Non-existent ref (error case)
echo "=== Test 3: Non-existent ref ==="
if git merge-base --is-ancestor "nonexistent-abc123" origin/main 2>&1; then
  echo "✗ FAIL: Non-existent ref should be rejected"
else
  echo "✓ PASS: Non-existent ref properly rejected"
fi

# Test 4: Tag name as ref
echo "=== Test 4: Tag as ref ==="
git tag v1.0.0 main
if git merge-base --is-ancestor v1.0.0 origin/main 2>&1; then
  echo "✓ PASS: Tag on main validated"
else
  echo "✗ FAIL: Tag on main rejected"
fi

# Test 5: Branch not ancestor of main
echo "=== Test 5: Branch not ancestor of main ==="
git checkout main
git checkout -b diverged
git revert --no-edit HEAD
git push origin diverged 2>/dev/null || true
if git merge-base --is-ancestor diverged origin/main 2>&1; then
  echo "✗ FAIL: Non-ancestor branch should be rejected"
else
  echo "✓ PASS: Non-ancestor branch properly rejected"
fi

Repository: triggerdotdev/trigger.dev

Length of output: 1917


🏁 Script executed:

cat -n .github/workflows/release.yml | sed -n '164,206p'

Repository: triggerdotdev/trigger.dev

Length of output: 1665


Add explicit git fetch before validating ref ancestry.

The validation at line 172 will fail because actions/checkout@v4 with fetch-depth: 0 does not automatically create the origin/main remote-tracking branch. This is a known issue with GitHub Actions runners (Git 2.50+). The command git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main will fail with "fatal: Not a valid object name origin/main".

Add an explicit fetch step between checkout and validation:

- name: Validate ref is on main
  run: |
    git fetch origin main --no-tags
    if ! git merge-base --is-ancestor ${{ github.event.inputs.ref }} origin/main; then
      echo "Error: ref must be an ancestor of main (i.e., already merged)"
      exit 1
    fi
🤖 Prompt for AI Agents
.github/workflows/release.yml around lines 170 to 175: the ancestry check uses
origin/main but the runner may not have the origin/main remote-tracking branch
available, causing "Not a valid object name origin/main"; fix by performing an
explicit git fetch of origin main (no tags) before running the merge-base check
so origin/main exists, then proceed with the existing git merge-base
--is-ancestor check and error/exit logic.


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

- name: Setup node
uses: buildjet/setup-node@v4
with:
node-version: 20.19.0
cache: "pnpm"

- name: Download deps
run: pnpm install --frozen-lockfile

- name: Generate Prisma Client
run: pnpm run generate

- name: Snapshot version
run: pnpm exec changeset version --snapshot ${{ github.event.inputs.tag }}

- name: Clean
run: pnpm run clean --filter "@trigger.dev/*" --filter "trigger.dev"

- name: Build
run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev"

- name: Publish prerelease
run: pnpm exec changeset publish --no-git-tag --snapshot --tag ${{ github.event.inputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}