Repository navigation
186 lines (158 loc) · 6.76 KB
/
Copy pathci.yml
File metadata and controls
186 lines (158 loc) · 6.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
# ── Detect changed packages ──────────────────────────────────────────────────
detect-changes:
name: Detect changed packages
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.changes.outputs.packages }}
has-changes: ${{ steps.changes.outputs.has_changes }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Detect changed packages
id: changes
run: |
# Compare against the last tagged commit (not the previous push commit),
# so that new changeset files added in prior pushes are still detected.
# Fall back to the previous commit SHA if no tags exist yet.
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
PREV_SHA=$(git rev-parse "$LAST_TAG" 2>/dev/null)
else
PREV_SHA="${{ github.event.before }}"
if [ "$PREV_SHA" == "0000000000000000000000000000000000000000" ]; then
PREV_SHA=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
fi
fi
echo "Comparing against: $PREV_SHA (last tag: $LAST_TAG)"
# Get list of changed AND added files since last tag
CHANGES=$(git diff --name-only $PREV_SHA HEAD 2>/dev/null)
echo "Changed files: $CHANGES"
PACKAGES=""
HAS_CHANGES="false"
for FILE in $CHANGES; do
case "$FILE" in
packages/orca-lang/*) PACKAGES="$PACKAGES orca-lang"; HAS_CHANGES="true" ;;
packages/runtime-ts/*) PACKAGES="$PACKAGES runtime-ts"; HAS_CHANGES="true" ;;
packages/mcp-server/*) PACKAGES="$PACKAGES mcp-server"; HAS_CHANGES="true" ;;
packages/runtime-python/*) PACKAGES="$PACKAGES runtime-python"; HAS_CHANGES="true" ;;
packages/runtime-go/*) PACKAGES="$PACKAGES runtime-go"; HAS_CHANGES="true" ;;
.changeset/*.md) HAS_CHANGES="true" ;;
esac
done
# Deduplicate
PACKAGES=$(echo "$PACKAGES" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ $//')
echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT"
echo "has_changes=$HAS_CHANGES" >> "$GITHUB_OUTPUT"
# ── Build and test on every push ────────────────────────────────────────────
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: '22'
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm build
- name: Test
run: pnpm test
# ── Version bump (only on main after build passes) ────────────────────────
version:
name: Version bump
runs-on: ubuntu-latest
needs: [detect-changes, build]
if: needs.detect-changes.outputs.has-changes == 'true' && github.ref == 'refs/heads/main'
outputs:
tag: v${{ steps.version.outputs.version }}
has-version-bump: ${{ steps.version.outputs.bumped }}
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v5
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create changeset for npm packages
run: |
PACKAGES="${{ needs.detect-changes.outputs.packages }}"
echo "Packages that changed: $PACKAGES"
# Only create changesets for npm packages (changesets doesn't handle Python/Go)
for PKG in $PACKAGES; do
case "$PKG" in
orca-lang) NAME="@orcalang/orca-lang" ;;
runtime-ts) NAME="@orcalang/orca-runtime-ts" ;;
mcp-server) NAME="@orcalang/orca-mcp-server" ;;
runtime-python) continue ;; # handled separately below
runtime-go) continue ;; # handled separately below
esac
echo "Creating changeset for npm package: $NAME"
echo -e "---\n\"$NAME\": patch\n---\n\nBump $NAME" > .changeset/ci-${PKG}.md
done
- name: Run changesets version (npm packages)
id: version
run: |
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ls .changeset/*.md 2>/dev/null | grep -v README.md > /dev/null; then
echo "Running changesets version for npm packages..."
pnpm changeset version
# Get the new version (all npm packages use the same version due to fixed)
VERSION=$(node -p "require('./packages/orca-lang/package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "bumped=true" >> "$GITHUB_OUTPUT"
else
echo "No changeset files found, skipping npm version bump"
echo "bumped=false" >> "$GITHUB_OUTPUT"
fi
- name: Bump Python package version
if: steps.version.outputs.bumped == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Bumping runtime-python to $VERSION"
# Update pyproject.toml: replace version line
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" packages/runtime-python/pyproject.toml
cat packages/runtime-python/pyproject.toml | grep "^version"
- name: Bump server.json version
if: steps.version.outputs.bumped == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Bumping server.json to $VERSION"
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/g" server.json
grep '"version"' server.json
- name: Push version bump commit
if: steps.version.outputs.bumped == 'true'
run: |
VERSION=${{ steps.version.outputs.version }}
git add -A
git commit -m "chore: bump all packages to v${VERSION}"
git push origin HEAD:${{ github.ref_name }}
# Tag and push
git tag "v${VERSION}"
git push origin "v${VERSION}"