Skip to content

Commit 0ad6e00

Browse files
committed
feat: auto publish flow daily trigger
1 parent 3bc5c02 commit 0ad6e00

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

.github/workflows/vsce-publish.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,74 @@
11
name: Publish Extension
22
permissions:
33
contents: read
4+
45
on:
5-
push:
6-
branches: [master]
6+
schedule:
7+
- cron: '0 0 * * *' # every day at 00:00 UTC
8+
workflow_dispatch: {} # allow manual runs
79

810
jobs:
911
publish:
10-
if: startsWith(github.ref, 'refs/tags/v')
1112
runs-on: ubuntu-latest
1213

1314
steps:
14-
- name: Checkout code
15+
- name: Checkout code (last 2 commits)
1516
uses: actions/checkout@v4
1617
with:
17-
ref: ${{ github.ref }}
18+
ref: refs/heads/master
19+
fetch-depth: 2
20+
21+
- name: Determine if package.json changed in the last commit
22+
id: pkg_changed
23+
run: |
24+
# if there is a previous commit available (fetch-depth:2 gives HEAD~1), diff only the root package.json
25+
if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
26+
CHANGED=$(git diff --name-only HEAD~1 HEAD -- package.json || true)
27+
else
28+
# fallback: list top-level files only (no -r) and match exact 'package.json' to avoid subfolder matches
29+
CHANGED=$(git ls-tree --name-only HEAD | grep -x 'package.json' || true)
30+
fi
31+
if [ -n "$CHANGED" ]; then
32+
echo "changed=true" >> $GITHUB_OUTPUT
33+
else
34+
echo "changed=false" >> $GITHUB_OUTPUT
35+
fi
1836
1937
- name: Setup Node.js
38+
if: steps.pkg_changed.outputs.changed == 'true'
2039
uses: actions/setup-node@v4
2140
with:
2241
node-version: '20'
2342

2443
- name: Install dependencies
44+
if: steps.pkg_changed.outputs.changed == 'true'
2545
run: |
2646
npm install
2747
cd views/chat-view
2848
npm install
2949
3050
- name: Install vsce
51+
if: steps.pkg_changed.outputs.changed == 'true'
3152
run: npm install -g vsce
3253

33-
- name: Publish
54+
- name: Package extension (.vsix)
55+
if: steps.pkg_changed.outputs.changed == 'true'
56+
run: |
57+
vsce package
58+
59+
- name: Publish to VS Code Marketplace
60+
if: steps.pkg_changed.outputs.changed == 'true'
3461
env:
3562
VSCE_PAT: ${{ secrets.VSCE_PAT }}
3663
run: vsce publish -p $VSCE_PAT
64+
65+
- name: Install ovsx
66+
if: steps.pkg_changed.outputs.changed == 'true'
67+
run: npm install -g ovsx
68+
69+
- name: Publish to Open VSX
70+
if: steps.pkg_changed.outputs.changed == 'true'
71+
env:
72+
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
73+
run: |
74+
ovsx publish *.vsix --pat $OVSX_TOKEN

0 commit comments

Comments
 (0)