diff --git a/.github/workflows/tact.yml b/.github/workflows/tact.yml index 9d8f995c8..b1464ed50 100644 --- a/.github/workflows/tact.yml +++ b/.github/workflows/tact.yml @@ -60,6 +60,11 @@ jobs: run: | yarn knip + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + scandir: "./scripts" + - name: Check there are no errors to be fixed in package.json run: | npm pkg fix && git diff --exit-code diff --git a/cspell.json b/cspell.json index 6ad870b53..6df46b2af 100644 --- a/cspell.json +++ b/cspell.json @@ -41,6 +41,7 @@ "maxint", "minmax", "mintable", + "mktemp", "multiformats", "Korshakov", "nocheck", diff --git a/scripts/set-next-version.sh b/scripts/set-next-version.sh new file mode 100755 index 000000000..898ad1cc8 --- /dev/null +++ b/scripts/set-next-version.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +# Call the script with a new dev version as its argument. +# If the argument is not provided a new version will be +# automatically generated from package.json and current date, +# plus a gitHead field with the current Git commit hash +# will be added to package.json. +# +# The version format should be as follows: +# ..-dev. +# e.g. something like 1.4.0-dev.20240711 + +FILE=package.json +COMMIT=$(git rev-parse HEAD) + +if [ ! -f "$FILE" ]; then + echo "Error: $FILE not found!" + exit 1 +fi + +VERSION=$1 +if [ -z "$VERSION" ]; then + VERSION=$(jq -r '.version' $FILE)-dev.$(date +"%Y%m%d") +fi + +TMP=$(mktemp) +jq ".version = \"$VERSION\" | .gitHead = \"$COMMIT\"" "$FILE" > "$TMP" +mv "$TMP" "$FILE" +rm "$TMP" +yarn prettier -w "$FILE" +