chore(release): v0.5.8 #37
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/publish.yml | |
| name: Publish to npm | |
| on: | |
| # パターン A: タグ push でトリガー | |
| push: | |
| tags: | |
| - 'v*' | |
| # パターン B: GitHub UI から手動実行 | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version type to bump' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| # 権限を明示的に設定 | |
| permissions: | |
| contents: write # 手動実行時の git push に必要 | |
| id-token: write # Trusted Publishing (OIDC) に必要 | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| # 無限ループ防止: bot からのタグ push はスキップ | |
| # - タグ push (ローカルから): github.actor = ユーザー → 実行 | |
| # - タグ push (手動実行後): github.actor = github-actions[bot] → スキップ | |
| # - 手動実行: main ブランチからのみ → 実行 | |
| if: | | |
| (github.event_name == 'push' && github.actor != 'github-actions[bot]') || | |
| (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Upgrade npm for OIDC support | |
| run: | | |
| echo "Before upgrade:" | |
| echo "Node.js version: $(node --version)" | |
| echo "npm version: $(npm --version)" | |
| npm install -g npm@latest | |
| echo "After upgrade:" | |
| echo "npm version: $(npm --version)" | |
| - name: Install pandoc | |
| run: | | |
| wget https://github.com/jgm/pandoc/releases/download/3.8/pandoc-3.8-1-amd64.deb | |
| sudo dpkg -i pandoc-3.8-1-amd64.deb | |
| pandoc --version | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # 手動実行時のみ: バージョンを bump (無限ループ防止のため手動でタグ作成) | |
| - name: Bump version (manual trigger only) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| npm version ${{ github.event.inputs.version }} --no-git-tag-version | |
| git add package.json package-lock.json | |
| VERSION=$(node -p "require('./package.json').version") | |
| git commit -m "chore: release v${VERSION}" | |
| git tag "v${VERSION}" | |
| git push origin main --tags | |
| # バージョン情報を取得 | |
| - name: Get version | |
| id: version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Run tests | |
| run: npm test | |
| - name: Publish to npm with OIDC | |
| run: npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: "" # Empty string to trigger OIDC authentication | |
| - name: Notify Discord on success | |
| if: success() | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| jq -n --arg msg "📦 **vimd v${VERSION}** published to npm - https://www.npmjs.com/package/vimd/v/${VERSION}" '{content: $msg}' > /tmp/payload.json | |
| cat /tmp/payload.json | |
| wget --header="Content-Type: application/json" --post-file=/tmp/payload.json -O - "${DISCORD_WEBHOOK}" || echo "wget failed with exit code $?" | |
| - name: Notify Discord on failure | |
| if: failure() | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| run: | | |
| jq -n --arg msg "❌ vimd npm publish failed - ${RUN_URL}" '{content: $msg}' > /tmp/payload.json | |
| cat /tmp/payload.json | |
| wget --header="Content-Type: application/json" --post-file=/tmp/payload.json -O - "${DISCORD_WEBHOOK}" || echo "wget failed with exit code $?" |