Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

バージョンアップ時にタグとリリースの作成を自動で行う #33

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ jobs:

- name: Create Release Pull Request
uses: changesets/action@v1
with:
publish: npm run dummy-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"format:check": "prettier --cache --check .",
"postinstall": "npm run download-uroborosql-fmt-napi && cd client && npm install && cd ../server && npm install && cd ..",
"test": "sh ./scripts/e2e.sh",
"download-uroborosql-fmt-napi": "node ./server/download-uroborosql-fmt-napi.mjs"
"download-uroborosql-fmt-napi": "node ./server/download-uroborosql-fmt-napi.mjs",
"dummy-release": "node ./scripts/dummy-publish.mjs"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
Expand Down
19 changes: 19 additions & 0 deletions scripts/dummy-publish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { readFileSync } from "node:fs";
import * as cp from "child_process";

main();

// 既に作成済みのバージョンのtagを再度作成しようとしてgithub actionが失敗するのを防ぐため
// tag作成が必要な場合のみ"New tag:"を出力する
function main() {
cp.execSync("git fetch --tags origin");

const tags = cp.execSync("git tag").toString().split("\n");
const changelog = readFileSync("CHANGELOG.md", "utf8");

const latestVersion = changelog.match(/^## (?<version>\d\.\d\.\d)/m);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG.mdから取るよりもpackage.jsonから取得する方が簡単ではないでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確かにそちらの方が簡単ですね!
後ほど修正しようと思います


if (!tags.includes(`v${latestVersion.groups.version}`)) {
console.log('"New tag:"');
}
}