From fca8baa81c3ccb685ce6796074d725c4f9aa962a Mon Sep 17 00:00:00 2001 From: yamada2915 Date: Fri, 27 Oct 2023 10:37:21 +0900 Subject: [PATCH 1/2] modify release.yml to create github release automatically --- .github/workflows/release.yml | 2 ++ package.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15b5b19..2343031 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/package.json b/package.json index a7a52a2..aa38e31 100644 --- a/package.json +++ b/package.json @@ -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": "echo \"New tag:\" && exit 0" }, "devDependencies": { "@changesets/changelog-github": "^0.4.8", From 3beb9e056a1091895711a6fa4d8077ccd5f7a603 Mon Sep 17 00:00:00 2001 From: yamada2915 Date: Fri, 27 Oct 2023 11:52:28 +0900 Subject: [PATCH 2/2] fix dummy-release script --- package.json | 2 +- scripts/dummy-publish.mjs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 scripts/dummy-publish.mjs diff --git a/package.json b/package.json index aa38e31..e9d1ea8 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "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", - "dummy-release": "echo \"New tag:\" && exit 0" + "dummy-release": "node ./scripts/dummy-publish.mjs" }, "devDependencies": { "@changesets/changelog-github": "^0.4.8", diff --git a/scripts/dummy-publish.mjs b/scripts/dummy-publish.mjs new file mode 100644 index 0000000..965de51 --- /dev/null +++ b/scripts/dummy-publish.mjs @@ -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(/^## (?\d\.\d\.\d)/m); + + if (!tags.includes(`v${latestVersion.groups.version}`)) { + console.log('"New tag:"'); + } +}