name: Version Bump
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Configure Git
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version
run: |
npm version ${{ github.event.inputs.version_type }} -m "chore: bump version to %s"
- name: Update manifest.json version
run: |
# package.jsonから新しいバージョンを取得
NEW_VERSION=$(node -p "require('./package.json').version")
# manifest.jsonのバージョンを更新
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$NEW_VERSION\"/" manifest.json
# 変更をコミット
git add manifest.json
git commit -m "chore: update manifest.json version to $NEW_VERSION"
- name: Push changes
run: |
git push origin main --follow-tags
- name: Build DXT package
run: |
npm install
npx @anthropic-ai/dxt pack
ls -la *.dxt
- name: Create Release with DXT
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const package = require('./package.json');
const version = package.version;
// リリースを作成
const { data: release } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${version}`,
name: `v${version}`,
body: `Release v${version}\n\n### Changes\n- Version bump to ${version}\n\n### Assets\n- \`repsona-mcp-server.dxt\` - MCP extension package`,
draft: false,
prerelease: false
});
console.log(`Created release ${release.html_url}`);
// .dxtファイルをアップロード
const dxtPath = 'repsona-mcp-server.dxt';
if (fs.existsSync(dxtPath)) {
const dxtContent = fs.readFileSync(dxtPath);
const { data: asset } = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
name: 'repsona-mcp-server.dxt',
data: dxtContent
});
console.log(`Uploaded DXT package: ${asset.browser_download_url}`);
} else {
console.error('DXT file not found!');
}