|
1 | 1 | name: Publish Extension |
2 | 2 | permissions: |
3 | 3 | contents: read |
| 4 | + |
4 | 5 | on: |
5 | | - push: |
6 | | - branches: [master] |
| 6 | + schedule: |
| 7 | + - cron: '0 0 * * *' # every day at 00:00 UTC |
| 8 | + workflow_dispatch: {} # allow manual runs |
7 | 9 |
|
8 | 10 | jobs: |
9 | 11 | publish: |
10 | | - if: startsWith(github.ref, 'refs/tags/v') |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 |
|
13 | 14 | steps: |
14 | | - - name: Checkout code |
| 15 | + - name: Checkout code (last 2 commits) |
15 | 16 | uses: actions/checkout@v4 |
16 | 17 | 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 |
18 | 36 |
|
19 | 37 | - name: Setup Node.js |
| 38 | + if: steps.pkg_changed.outputs.changed == 'true' |
20 | 39 | uses: actions/setup-node@v4 |
21 | 40 | with: |
22 | 41 | node-version: '20' |
23 | 42 |
|
24 | 43 | - name: Install dependencies |
| 44 | + if: steps.pkg_changed.outputs.changed == 'true' |
25 | 45 | run: | |
26 | 46 | npm install |
27 | 47 | cd views/chat-view |
28 | 48 | npm install |
29 | 49 |
|
30 | 50 | - name: Install vsce |
| 51 | + if: steps.pkg_changed.outputs.changed == 'true' |
31 | 52 | run: npm install -g vsce |
32 | 53 |
|
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' |
34 | 61 | env: |
35 | 62 | VSCE_PAT: ${{ secrets.VSCE_PAT }} |
36 | 63 | 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