Skip to content

Merge pull request #58 from microsoft/optimizations #83

Merge pull request #58 from microsoft/optimizations

Merge pull request #58 from microsoft/optimizations #83

Workflow file for this run

name: Build and Release
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "src/**"
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
concurrency:
group: flowquery-release-${{ github.ref_name }}
cancel-in-progress: false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build project
run: npm run build
- name: Verify build artifacts
run: |
echo "Checking build artifacts..."
ls -la dist/flowquery.min.js || echo "dist/flowquery.min.js not found"
- name: Copy to VS Code extension
run: |
echo "Copying flowquery.min.js to VS Code extension..."
mkdir -p flowquery-vscode/flowQueryEngine
cp dist/flowquery.min.js flowquery-vscode/flowQueryEngine/
ls -la flowquery-vscode/flowQueryEngine/
- name: Bump version
id: version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Bump patch version (use 'minor' or 'major' for other bump types)
npm version patch --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
echo "tag=v${NEW_VERSION}" >> $GITHUB_OUTPUT
# Sync VS Code extension version
cd flowquery-vscode
npm version "${NEW_VERSION}" --no-git-tag-version
cd ..
# Commit the version bump
git add package.json package-lock.json flowquery-vscode/package.json
git commit --no-verify -m "chore: bump version to ${NEW_VERSION} [skip ci]"
# Include any changes from formatters/linters in the commit
git add -A
git diff --cached --quiet || git commit --amend --no-verify --no-edit
# Retry the rebase/push sequence in case another workflow updates main first.
for attempt in 1 2 3; do
git fetch origin main:refs/remotes/origin/main
if ! git rebase origin/main; then
git rebase --abort || true
elif git push origin HEAD:main; then
break
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to push version bump after 3 attempts."
exit 1
fi
sleep 5
done
- name: Install VS Code extension dependencies
working-directory: ./flowquery-vscode
run: |
npm install @vscode/vsce
- name: Package VS Code extension
working-directory: ./flowquery-vscode
run: |
npx @vscode/vsce package
ls -la *.vsix
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.PAT_TOKEN }}
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body: |
Automated release from main branch
Version: ${{ steps.version.outputs.version }}
Commit: ${{ github.sha }}
files: |
dist/flowquery.min.js
flowquery-vscode/*.vsix
draft: false
prerelease: false