mcpField
R
release-automation-builder

release-automation-builder

github.com/patricio0312revクラウド・DevOps63252 回インストール41 週間前に更新
リポジトリ

release-automation-builder について

release-automation-builderは、ソフトウェアリリースの自動化を設定するスキルです。Changesetsまたはsemantic-releaseを使ったバージョン管理、変更履歴、リリースノート、公開を扱います。

主な機能

  1. 01Changesetsまたはsemantic-releaseの設定
  2. 02SemVerとConventional Commitsの適用
  3. 03変更履歴とリリースノートの自動生成
  4. 04NPMパッケージとDockerイメージの公開
  5. 05GitタグとGitHubリリースの自動作成

活用シーン

  1. 01mainへの更新を契機とするリリース設定
  2. 02テスト後のNPMパッケージ公開
  3. 03バージョン付きDockerイメージのリリース

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/patricio0312rev/skills --skill release-automation-builder

インストール後、Claude Code で/release-automation-builderを入力して読み込まれたか確認します。

詳細

リリース自動化ビルダー

バージョン管理、変更履歴、公開を自動化します。

Changesets を使用する

セットアップ
npm install -D @changesets/cli
npx changeset init
ワークフロー
# .github/workflows/release.yml
name: Release

on:
  push:
    branches:
      - main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "npm"

      - run: npm ci

      - name: Create Release Pull Request or Publish
        uses: changesets/action@v1
        with:
          publish: npm run release
          commit: "chore: release packages"
          title: "chore: release packages"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
パッケージスクリプト
{
  "scripts": {
    "changeset": "changeset",
    "version": "changeset version",
    "release": "changeset publish"
  }
}

Semantic Release を使用する

設定
// .releaserc.js
module.exports = {
  branches: ["main"],
  plugins: [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/github",
    [
      "@semantic-release/git",
      {
        assets: ["CHANGELOG.md", "package.json"],
        message:
          "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
      },
    ],
  ],
};
ワークフロー
# .github/workflows/release.yml
name: Release

on:
  push:
    branches: [main]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false

      - uses: actions/setup-node@v4
        with:
          node-version: "20"

      - run: npm ci
      - run: npm run build

      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npx semantic-release

バージョン管理戦略

セマンティックバージョニング(SemVer)
MAJOR.MINOR.PATCH

1.0.0 → 1.0.1  (patch - bug fix)
1.0.1 → 1.1.0  (minor - new feature)
1.1.0 → 2.0.0  (major - breaking change)
Conventional Commits
feat: add new feature (minor bump)
fix: fix bug (patch bump)
perf: performance improvement (patch bump)
docs: update docs (no bump)
chore: maintenance (no bump)

feat!: breaking change (major bump)
fix!: breaking bug fix (major bump)

変更履歴の生成

# Changelog

## [2.1.0] - 2024-01-15

### Added

- New dashboard widget (#123)
- Export to PDF feature (#125)

### Fixed

- Memory leak in data processing (#124)
- Typo in error message (#126)

### Changed

- Updated dependencies

## [2.0.0] - 2024-01-01

### Breaking Changes

- Removed deprecated API endpoints
- Changed authentication method

### Migration Guide

See MIGRATION.md for upgrade instructions

Docker イメージの公開

docker-release:
  runs-on: ubuntu-latest
  needs: test
  if: github.ref == 'refs/heads/main'
  steps:
    - uses: actions/checkout@v4

    - name: Get version
      id: version
      run: echo "version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT

    - name: Login to Docker Hub
      uses: docker/login-action@v3
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}

    - name: Build and push
      uses: docker/build-push-action@v5
      with:
        context: .
        push: true
        tags: |
          mycompany/myapp:latest
          mycompany/myapp:${{ steps.version.outputs.version }}

NPM への公開

publish:
  runs-on: ubuntu-latest
  needs: test
  if: github.event_name == 'release'
  steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
        node-version: "20"
        registry-url: "https://registry.npmjs.org"

    - run: npm ci
    - run: npm run build

    - name: Publish to npm
      run: npm publish
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

GitHub リリースノート

- name: Create GitHub Release
  uses: actions/create-release@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    tag_name: v${{ steps.version.outputs.version }}
    release_name: Release ${{ steps.version.outputs.version }}
    body: |
      ## What's Changed
      ${{ steps.changelog.outputs.content }}

      ## Installation
      ```bash
      npm install mypackage@${{ steps.version.outputs.version }}
      ```
    draft: false
    prerelease: false

ベストプラクティス

  1. Conventional Commits:コミット形式を標準化します
  2. 保護されたブランチ:main への直接プッシュを防止します
  3. バージョン管理の自動化:ツールにバージョンを決定させます
  4. 変更履歴:コミットから自動生成します
  5. Git タグ:すべてのリリースにタグを付けます
  6. リリースノート:移行ガイドを含めます
  7. ドライラン:ステージング環境でリリースをテストします

出力チェックリスト

  • Changesets または semantic-release が設定されている
  • バージョン管理戦略が文書化されている
  • 変更履歴の生成が自動化されている
  • Git タグ付けが自動化されている
  • リリースノートのテンプレートがある
  • NPM への公開(パッケージの場合)
  • Docker の公開(該当する場合)
  • 保護されたブランチのルール

コメント