diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 21b60a7..cdea623 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,53 +1,18 @@ name: "Release" -on: - push: - tags: - - "*" +on: workflow_dispatch +permissions: + contents: write jobs: release: runs-on: ubuntu-latest - permissions: - contents: write steps: - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v1 - - - run: bun ci - - - name: Create Release - id: create_release - uses: softprops/action-gh-release@v2 - with: - draft: true - files: | - main.js - styles.css - manifest.json - manifest-beta.json - - - name: "Discord notification (not success)" - uses: rjstone/discord-webhook-notify@v1 - if: "! success()" - with: - description: "⚠ Silhouette Release failed!" - details: "${{ github.ref }}" - severity: error - avatarUrl: https://www.suruga-ya.jp/database/pics_light/game/871005085.jpg - webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} - - notify: - needs: release - runs-on: ubuntu-latest - - steps: - - name: "Discord notification (success)" - uses: rjstone/discord-webhook-notify@v1 - if: always() + - uses: oven-sh/setup-bun@v2 + - run: npm i -D --no-save conventional-changelog-conventionalcommits @semantic-release/git @semantic-release/exec + - uses: cycjimmy/semantic-release-action@v4 with: - description: "🚀 Silhouette Release finished!" - details: "${{ github.ref }}" - severity: info - avatarUrl: https://www.suruga-ya.jp/database/pics_light/game/871005085.jpg - webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} + semantic_version: 24.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5c61891..ef6ba16 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,39 +8,11 @@ on: - "src/**/*" - "*.js" - "*.json" - schedule: - - cron: "0 0 * * *" jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v1 - + - uses: oven-sh/setup-bun@v2 - run: bun ci - - - name: "Discord notification (not success)" - uses: rjstone/discord-webhook-notify@v1 - if: "! success()" - with: - description: "⚠ Silhouette Tests failed!" - footer: "Bun" - severity: error - avatarUrl: https://cdn.otamart.com/item-picture/26205822/0-1574353123758.jpg - webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} - - notify: - needs: test - runs-on: ubuntu-latest - - steps: - - name: "Discord notification (success)" - uses: rjstone/discord-webhook-notify@v1 - if: always() - with: - description: "✅ Silhouette Tests passed!" - footer: "Bun" - severity: info - avatarUrl: https://cdn.otamart.com/item-picture/26205822/0-1574353123758.jpg - webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.releaserc.mjs b/.releaserc.mjs new file mode 100644 index 0000000..8c506aa --- /dev/null +++ b/.releaserc.mjs @@ -0,0 +1,76 @@ +export default { + branches: ["master"], + // Obsidianプラグインはgit tagにvをつけてはいけないのでtagFormatを変更 + tagFormat: "${version}", + plugins: [ + [ + "@semantic-release/commit-analyzer", + { + preset: "conventionalcommits", + releaseRules: [ + { breaking: true, release: "minor" }, // TODO: v1になったら release: "major" にする + { type: "feat", release: "minor" }, + { type: "build", release: "minor" }, + { type: "style", release: "minor" }, + { type: "fix", release: "patch" }, + { type: "refactor", release: "patch" }, + { revert: true, release: "patch" }, + ], + }, + ], + [ + "@semantic-release/release-notes-generator", + { + preset: "conventionalcommits", + presetConfig: { + types: [ + { type: "feat", section: "✨ Features" }, + { type: "style", section: "🎨 Styles" }, + { type: "fix", section: "🛡 Bug Fixes" }, + { type: "build", section: "🤖 Build" }, + { type: "docs", hidden: true }, + { type: "refactor", hidden: true }, + { type: "test", hidden: true }, + { type: "ci", hidden: true }, + { type: "dev", hidden: true }, + { type: "chore", hidden: true }, + ], + }, + }, + ], + [ + "@semantic-release/exec", + { + // リリース作業直前にCIでビルド・テストを行い、version-bump.mtsでバージョン更新処理を行う. ${nextRelease.version}はsemantic-releaseが決めたバージョン + prepareCmd: "bun ci && bun version-bump.mts ${nextRelease.version}", + }, + ], + [ + "@semantic-release/github", + { + // Obsidianプラグインとして配布する必要のあるファイルを記載 + assets: [ + "main.js", + "styles.css", + "manifest.json", + "manifest-beta.json", + ], + }, + ], + [ + "@semantic-release/git", + { + // bun version-bump.mts で変更されたファイルすべてをコミット対象とする + assets: [ + "package.json", + "manifest-beta.json", + "manifest.json", + "versions.json", + "bun.lockb", + ], + message: + "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", + }, + ], + ], +}; diff --git a/README.md b/README.md index f0fba67..21450be 100644 --- a/README.md +++ b/README.md @@ -676,12 +676,19 @@ Su Mo Tu We Th Fr Sa ## 開発者向け +### セットアップ + 以下でhooksの場所を変更する。 ```bash git config core.hooksPath hooks ``` +### リリース + +[Release Action] を実行。 + + [ワンタイムタスク]: #ワンタイムタスク [繰り返しタスク]: #繰り返しタスク [繰り返しタスクファイル]: #繰り返しタスクファイル @@ -704,3 +711,4 @@ git config core.hooksPath hooks [Silhouette: Insert tasks]: #silhouette-insert-tasks [複数パターン指定]: #複数パターン指定 [繰り返しパターン]: #繰り返しパターン +[Release Action]: https://github.com/tadashi-aikawa/mobile-first-daily-interface/actions/workflows/release.yaml diff --git a/package.json b/package.json index 80a6482..337d8b0 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ "prepare": "husky install", "pre:push": "tsc -noEmit -skipLibCheck && bun run test", "test": "jest", - "ci": "bun install && bun run build && bun run test", - "release": "bun ci && bun version-bump.mts ${VERSION} && git add package.json manifest-beta.json manifest.json versions.json bun.lockb && git commit -m ${VERSION} && git tag ${VERSION} && git push --tags && git push" + "ci": "bun install && bun run build && bun run test" }, "keywords": [], "author": "", @@ -41,4 +40,5 @@ "@tadashi-aikawa/silhouette-core": "npm:@jsr/tadashi-aikawa__silhouette-core", "owlelia": "^0.48.1" } -} \ No newline at end of file +} +