Skip to content
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
12 changes: 12 additions & 0 deletions .github/changeset-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/sh
# This script is called by the changeset action in release.yml.

set -e

npx changeset version

# The standard step is only to run `changeset version` but this does not update the
# package-lock.json file. So we also run `npm install`, which does this update.
# This is a workaround until this is handled automatically by `changeset version`.
# See https://github.com/changesets/changesets/issues/421.
npm install
23 changes: 23 additions & 0 deletions .github/version-script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as fs from "node:fs";
import { execSync } from "node:child_process";
async function main() {
try {
console.log("Getting current git hash...");
const stdout = execSync("git rev-parse --short HEAD").toString();
console.log("Git hash:", stdout.trim());

const path = "./package.json";
const packageJson = JSON.parse(fs.readFileSync(path, "utf-8"));
packageJson.version = `0.0.0-${stdout.trim()}`;
fs.writeFileSync(path, `${JSON.stringify(packageJson, null, 2)}\n`);
} catch (error) {
console.error(error);
process.exit(1);
}
}

main().catch((err) => {
// Build failures should fail
console.error(err);
process.exit(1);
});
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ jobs:
- id: changesets
uses: changesets/action@v1
with:
# The standard step is only to run `changeset version` but this does not update the
# package-lock.json file. So we also run `npm install`, which does this update.
# This is a workaround until this is handled automatically by `changeset version`.
# See https://github.com/changesets/changesets/issues/421.
version: bash -c 'npx changeset version && npm install'
# Note that these commands are NOT interpreted by a shell, they are apparently only
# split on whitespace and then passed directly to execvp(). Hence the need to indirect
# through a shell script, ugh. :(
version: ./github/changeset-version.sh
publish: npx changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Loading