diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4bb735..d86954c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,6 @@ name: Release on: - release: - types: [published] + workflow_dispatch: env: PLUGIN_NAME: obsidian-interval-timer jobs: @@ -11,8 +10,25 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js uses: actions/setup-node@v1 + id: release-drafter-prepare with: node-version: "16.x" + - name: Update draft + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Update version + run: | + node ./bin/version-bump.mjs ${{ steps.release-drafter.outputs.tag_name }} + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Update version to ${{ steps.release-drafter.outputs.tag_name }}" + - name: Publish release + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + publish: true - name: Build id: build run: | diff --git a/version-bump.mjs b/bin/version-bump.mjs similarity index 89% rename from version-bump.mjs rename to bin/version-bump.mjs index d409fa0..3eea32c 100644 --- a/version-bump.mjs +++ b/bin/version-bump.mjs @@ -1,14 +1,14 @@ import { readFileSync, writeFileSync } from "fs"; -const targetVersion = process.env.npm_package_version; +const targetVersion = process.argv[2]; // read minAppVersion from manifest.json and bump version to target version let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); const { minAppVersion } = manifest; manifest.version = targetVersion; -writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); +writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t") + "\n"); // update versions.json with target version and minAppVersion from manifest.json let versions = JSON.parse(readFileSync("versions.json", "utf8")); versions[targetVersion] = minAppVersion; -writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); +writeFileSync("versions.json", JSON.stringify(versions, null, "\t") + "\n"); diff --git a/package.json b/package.json index 3cb6c51..ecc0b23 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "scripts": { "dev": "node esbuild.config.mjs", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", - "version": "node version-bump.mjs && git add manifest.json versions.json", "prepare": "husky install" }, "lint-staged": { diff --git a/versions.json b/versions.json index 26382a1..2c63c08 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,2 @@ { - "1.0.0": "0.15.0" }