|
1 | 1 | name: Publish Extension |
2 | 2 |
|
3 | | -permissions: |
4 | | - contents: read |
| 3 | +# main への push で patch バージョンを自動 bump し、VS Code Marketplace に publish する。 |
| 4 | +# bot のコミットは GITHUB_TOKEN によるものなので再度ワークフローを起こさない(無限ループ防止)。 |
5 | 5 |
|
6 | 6 | on: |
7 | 7 | push: |
8 | 8 | branches: |
9 | 9 | - main |
| 10 | + paths-ignore: |
| 11 | + - 'README.md' |
| 12 | + - 'CHANGELOG.md' |
| 13 | + - 'LICENSE' |
| 14 | + - 'SECURITY.md' |
| 15 | + - 'vsc-extension-quickstart.md' |
| 16 | + - '.github/**' |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: publish-extension |
| 23 | + cancel-in-progress: false |
10 | 24 |
|
11 | 25 | jobs: |
12 | 26 | publish: |
13 | 27 | runs-on: ubuntu-latest |
14 | 28 | steps: |
15 | 29 | - uses: actions/checkout@v4 |
16 | | - with: |
17 | | - fetch-depth: 2 |
18 | | - |
19 | | - - name: Check if version changed |
20 | | - id: version |
21 | | - run: | |
22 | | - CURRENT=$(node -p "require('./package.json').version") |
23 | | - git show HEAD~1:package.json > /tmp/prev-package.json 2>/dev/null || echo '{}' > /tmp/prev-package.json |
24 | | - PREVIOUS=$(node -p "require('/tmp/prev-package.json').version || 'none'") |
25 | | - echo "current=$CURRENT, previous=$PREVIOUS" |
26 | | - if [ "$CURRENT" != "$PREVIOUS" ]; then |
27 | | - echo "changed=true" >> "$GITHUB_OUTPUT" |
28 | | - else |
29 | | - echo "changed=false" >> "$GITHUB_OUTPUT" |
30 | | - echo "Version unchanged ($CURRENT) - skipping publish." |
31 | | - fi |
32 | 30 |
|
33 | 31 | - uses: actions/setup-node@v4 |
34 | | - if: steps.version.outputs.changed == 'true' |
35 | 32 | with: |
36 | 33 | node-version: 20 |
| 34 | + cache: npm |
37 | 35 |
|
38 | 36 | - run: npm ci |
39 | | - if: steps.version.outputs.changed == 'true' |
40 | 37 |
|
41 | | - - run: npx vsce publish -p ${{ secrets.VSCE_PAT }} |
42 | | - if: steps.version.outputs.changed == 'true' |
| 38 | + - name: Bump patch version |
| 39 | + id: bump |
| 40 | + run: | |
| 41 | + git config user.name "github-actions[bot]" |
| 42 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 43 | + NEW_VERSION=$(npm version patch --no-git-tag-version) |
| 44 | + echo "version=${NEW_VERSION#v}" >> "$GITHUB_OUTPUT" |
| 45 | + git add package.json package-lock.json |
| 46 | + git commit -m "chore: release ${NEW_VERSION}" |
| 47 | + git push |
| 48 | +
|
| 49 | + - name: Publish to VS Code Marketplace |
| 50 | + env: |
| 51 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 52 | + run: npx vsce publish |
| 53 | + |
| 54 | + - name: Tag release |
| 55 | + run: | |
| 56 | + git tag "v${{ steps.bump.outputs.version }}" |
| 57 | + git push origin "v${{ steps.bump.outputs.version }}" |
0 commit comments