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
144 changes: 71 additions & 73 deletions .github/workflows/check-upstream.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,92 @@
name: Check Upstream Updates
name: Upstream Upgrade

on:
schedule:
- cron: '0 9 * * *'
workflow_dispatch:
inputs:
version:
description: 'sqlparser version (blank = latest)'
required: false

permissions:
issues: write
contents: write
pull-requests: write

jobs:
check:
upgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get current version
id: current
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- uses: Swatinem/rust-cache@v2

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Resolve versions
id: ver
run: |
CURRENT=$(grep 'sqlparser = { version' Cargo.toml | grep -oP '"\K[0-9.]+')
echo "version=$CURRENT" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT"
LATEST="${{ github.event.inputs.version }}"
if [ -z "$LATEST" ]; then
LATEST=$(cargo search sqlparser --limit 1 | grep -oP '^sqlparser = "\K[^"]+')
fi
echo "current=$CURRENT" >> $GITHUB_OUTPUT
echo "latest=$LATEST" >> $GITHUB_OUTPUT
[ "$CURRENT" = "$LATEST" ] && echo "needs=false" >> $GITHUB_OUTPUT || echo "needs=true" >> $GITHUB_OUTPUT
echo "Current: $CURRENT, Latest: $LATEST"

- name: Get latest upstream version
id: latest
- name: Apply upgrade
if: steps.ver.outputs.needs == 'true'
run: |
LATEST=$(cargo search sqlparser --limit 1 | grep -oP 'sqlparser = "\K[^"]+')
echo "version=$LATEST" >> $GITHUB_OUTPUT
echo "Latest version: $LATEST"
./scripts/upgrade.sh ${{ steps.ver.outputs.latest }}
cargo update -p sqlparser --precise ${{ steps.ver.outputs.latest }}

- name: Install npm dependencies
if: steps.ver.outputs.needs == 'true'
run: npm ci

- name: Compare versions
id: compare
- name: Install wasm-pack
if: steps.ver.outputs.needs == 'true'
uses: jetli/wasm-pack-action@v0.4.0

- name: Build and test
id: verify
if: steps.ver.outputs.needs == 'true'
continue-on-error: true
run: |
if [ "${{ steps.current.outputs.version }}" != "${{ steps.latest.outputs.version }}" ]; then
echo "needs_update=true" >> $GITHUB_OUTPUT
echo "🆕 New version available!"
else
echo "needs_update=false" >> $GITHUB_OUTPUT
echo "✅ Already up to date"
fi
wasm-pack build --target web --out-dir wasm
npm run build:ts
npm test

- name: Create issue for update
if: steps.compare.outputs.needs_update == 'true'
uses: actions/github-script@v7
- name: Create pull request
if: steps.ver.outputs.needs == 'true'
uses: peter-evans/create-pull-request@v6
with:
script: |
const current = '${{ steps.current.outputs.version }}';
const latest = '${{ steps.latest.outputs.version }}';

// Check if issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'upstream-update'
});

const existingIssue = issues.data.find(i => i.title.includes(latest));
if (existingIssue) {
console.log('Issue already exists:', existingIssue.html_url);
return;
}

// Create new issue
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `⬆️ Upgrade to sqlparser v${latest}`,
labels: ['upstream-update'],
body: `## New upstream version available

| | Version |
|---|---|
| Current | \`${current}\` |
| Latest | \`${latest}\` |

## Changelog

https://github.com/apache/datafusion-sqlparser-rs/releases/tag/v${latest}

## Checklist

- [ ] Run \`./scripts/upgrade.sh ${latest}\`
- [ ] Check for new dialects
- [ ] Check for AST changes
- [ ] Update \`src/types/ast.ts\` if needed
- [ ] Run \`./scripts/build.sh\`
- [ ] Run tests: \`npm test\`
- [ ] Update README if needed
- [ ] Publish to npm
`
});

console.log('Created issue:', issue.data.html_url);
branch: upgrade/sqlparser-${{ steps.ver.outputs.latest }}
title: '⬆️ Upgrade to sqlparser v${{ steps.ver.outputs.latest }}'
commit-message: 'chore: upgrade to sqlparser v${{ steps.ver.outputs.latest }}'
labels: upstream-update
draft: ${{ steps.verify.outcome != 'success' }}
body: |
Automated upgrade `${{ steps.ver.outputs.current }}` → `${{ steps.ver.outputs.latest }}`.

Build and test: **${{ steps.verify.outcome }}** (opened as draft if not success).

Changelog: https://github.com/apache/datafusion-sqlparser-rs/releases/tag/v${{ steps.ver.outputs.latest }}

## Review checklist
- [ ] New dialects in `src/lib.rs` + `src/dialects.ts`
- [ ] AST changes mirrored in `src/types/ast.ts`
- [ ] README updated if needed

After merge, tag `v${{ steps.ver.outputs.latest }}` to publish.
9 changes: 5 additions & 4 deletions scripts/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

echo "Upgrading to sqlparser v${VERSION}..."

# perl -i is portable across macOS (BSD) and CI (GNU); sed -i differs
# Update Cargo.toml
sed -i '' "s/sqlparser = { version = \"[^\"]*\"/sqlparser = { version = \"${VERSION}\"/" "$PROJECT_DIR/Cargo.toml"
sed -i '' "s/^version = \"[^\"]*\"/version = \"${VERSION}\"/" "$PROJECT_DIR/Cargo.toml"
perl -i -pe "s/sqlparser = \{ version = \"[^\"]*\"/sqlparser = { version = \"${VERSION}\"/" "$PROJECT_DIR/Cargo.toml"
perl -i -pe "s/^version = \"[^\"]*\"/version = \"${VERSION}\"/" "$PROJECT_DIR/Cargo.toml"

# Update package.json
sed -i '' "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" "$PROJECT_DIR/package.json"
perl -i -pe "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" "$PROJECT_DIR/package.json"

# Update README badge
sed -i '' "s/sqlparser--rs-v[0-9.]*-orange/sqlparser--rs-v${VERSION}-orange/" "$PROJECT_DIR/README.md"
perl -i -pe "s/sqlparser--rs-v[0-9.]*-orange/sqlparser--rs-v${VERSION}-orange/" "$PROJECT_DIR/README.md"

echo ""
echo "Updated to v${VERSION}. Next steps:"
Expand Down