Skip to content

Commit

Permalink
ci: semantic-release導入とCI環境を最新化
Browse files Browse the repository at this point in the history
  • Loading branch information
tadashi-aikawa committed Oct 30, 2024
1 parent 647c770 commit 4d34327
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 76 deletions.
53 changes: 9 additions & 44 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
30 changes: 1 addition & 29 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
76 changes: 76 additions & 0 deletions .releaserc.mjs
Original file line number Diff line number Diff line change
@@ -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}",
},
],
],
};
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,19 @@ Su Mo Tu We Th Fr Sa

## 開発者向け

### セットアップ

以下でhooksの場所を変更する。

```bash
git config core.hooksPath hooks
```

### リリース

[Release Action] を実行。


[ワンタイムタスク]: #ワンタイムタスク
[繰り返しタスク]: #繰り返しタスク
[繰り返しタスクファイル]: #繰り返しタスクファイル
Expand All @@ -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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -41,4 +40,5 @@
"@tadashi-aikawa/silhouette-core": "npm:@jsr/tadashi-aikawa__silhouette-core",
"owlelia": "^0.48.1"
}
}
}

0 comments on commit 4d34327

Please sign in to comment.