Skip to content

Commit

Permalink
Merge pull request #169 from drashland/chore/pre-check-release
Browse files Browse the repository at this point in the history
ci: pre-check release version when releasing to node ecosystem
  • Loading branch information
crookse authored Jul 3, 2022
2 parents 80d8265 + 88b1704 commit bfb25d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Release
on:
release:
types: [published]

# In the even this workflow fails, it can be started manually via `workflow_dispatch`
workflow_dispatch:

jobs:
Expand All @@ -17,6 +19,10 @@ jobs:
- name: Install Deno
uses: denoland/setup-deno@v1

- name: Pre-check release version
run: |
deno run --allow-read ./console/pre_check_release.ts ${{ github.event.release.tag_name }}
# Setup .npmrc file to publish to npm
- name: Install Node
uses: actions/setup-node@v2
Expand Down
19 changes: 19 additions & 0 deletions console/pre_check_release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const versionToPublish = Deno.args[0];

const packageJsonContents = new TextDecoder().decode(
Deno.readFileSync("./package.json"),
);

const packageJson = JSON.parse(packageJsonContents);
const packageJsonVersion = `v${packageJson.version}`;

console.log("Checking package.json version with GitHub release tag version.\n");
console.log(`packge.json version: ${packageJsonVersion}`);
console.log(`GitHub release version: ${versionToPublish}\n`);

if (packageJsonVersion !== versionToPublish) {
console.log("Version mismatch. Stopping Release workflow.");
Deno.exit(1);
} else {
console.log("Versions match. Proceeding with Release workflow.");
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"license": "MIT",
"scripts": {
"build": "console/build_esm_lib && yarn build:cjs && yarn build:esm",
"build:windows": "bash console/build_esm_lib && yarn build:cjs && yarn build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:conversion-workspace": "deno run --allow-read --allow-write ./console/build_esm_lib.ts",
"build:esm": "tsc --project tsconfig.esm.json",
"build:windows": "bash console/build_esm_lib && yarn build:cjs && yarn build:esm",
"check": "rm -rf node_modules/ && rm yarn.lock && yarn install && yarn build && yarn test",
"test": "jest"
},
Expand Down

0 comments on commit bfb25d9

Please sign in to comment.