Skip to content

Commit

Permalink
Replacing changelog-header.sh with a TypeScript equivalent (#6587)
Browse files Browse the repository at this point in the history
* Replacing a failing bash script with a TS script

* Updated workflows to use the new TS script

* Update .github/workflows/publish-package-release.yml
  • Loading branch information
kraenhansen authored Apr 4, 2024
1 parent 7872d2f commit 86eb923
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish-package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ jobs:
continue-on-error: true

- name: Update Changelog
working-directory: ${{ github.workspace }}/${{ env.PACKAGE_PATH }}
run: ${{ github.workspace }}/scripts/changelog-header.sh
run: npm run prepend-changelog-header -- ${{ github.workspace }}/${{ env.PACKAGE_PATH }}/CHANGELOG.md

- name: Create vNext PR
id: vnext-pr
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
continue-on-error: true

- name: Update Changelog
run: ${{ github.workspace }}/scripts/changelog-header.sh
run: npm run prepend-changelog-header

- name: Create vNext PR
id: vnext-pr
Expand Down
12 changes: 0 additions & 12 deletions scripts/changelog-header.sh → CHANGELOG.header.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#!/bin/bash

set -e
set -o pipefail

CHANGELOG=$(cat <<EOF
## vNext (TBD)

### Deprecations
Expand All @@ -25,9 +19,3 @@ CHANGELOG=$(cat <<EOF
<!-- * Either mention core version or upgrade -->
<!-- * Using Realm Core vX.Y.Z -->
<!-- * Upgraded Realm Core from vX.Y.Z to vA.B.C -->
$(cat CHANGELOG.md)
EOF
)

echo "$CHANGELOG" > CHANGELOG.md
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint:fix": "wireit",
"lint:cpp": "find src packages/realm/bindgen/src -name '*.cpp' -or -name '*.h' -or -name '*.hpp' | xargs clang-format --dry-run --Werror",
"lint:cpp:fix": "find src packages/realm/bindgen/src -name '*.cpp' -or -name '*.h' -or -name '*.hpp' | xargs clang-format -i",
"clean": "git clean -fdx -e node_modules -e .env"
"clean": "git clean -fdx -e node_modules -e .env",
"prepend-changelog-header": "tsx scripts/prepend-changelog-header.ts"
},
"wireit": {
"build": {
Expand Down
13 changes: 13 additions & 0 deletions scripts/prepend-changelog-header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fs from "node:fs";
import path from "node:path";

const headerPath = path.resolve(__dirname, "../CHANGELOG.header.md");
const header = fs.readFileSync(headerPath, "utf8").trim();

const changelogPathInput = process.argv[2] || path.resolve(__dirname, "../CHANGELOG.md");
const changelogPath = path.resolve(changelogPathInput);

console.log(`Prepending header to ${changelogPath}`);
const changelog = fs.readFileSync(changelogPath, "utf8");
const prependedChangelog = header + "\n\n" + changelog;
fs.writeFileSync(changelogPath, prependedChangelog, "utf8");

0 comments on commit 86eb923

Please sign in to comment.