-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (100 loc) · 3.52 KB
/
release.yml
File metadata and controls
123 lines (100 loc) · 3.52 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
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