diff --git a/.github/workflows/publish-to.sh b/.github/workflows/publish-to.sh index b577ff70..3ca74829 100755 --- a/.github/workflows/publish-to.sh +++ b/.github/workflows/publish-to.sh @@ -7,13 +7,13 @@ v="${1%%+*}" t="${2}" cd lib -for f in {,tdf3/}src/version.ts; do - if ! sed "s/export const version = \'[^']\{1,\}\';\$/export const version = \'${v}\';/" "${f}" >"${f}.tmp"; then - echo "Failed to insert version [${v}] into file [$f]" - exit 1 - fi - mv "${f}.tmp" "${f}" -done +f=src/version.ts +if ! sed "s/export const version = \'[^']\{1,\}\';\$/export const version = \'${v}\';/" "${f}" >"${f}.tmp"; then + echo "Failed to insert version [${v}] into file [$f]" + exit 1 +fi +mv "${f}.tmp" "${f}" + npm version --no-git-tag-version --allow-same-version "$v" npm publish --access public --tag "$t" diff --git a/lib/src/version.ts b/lib/src/version.ts index a16104fa..49c3cf27 100644 --- a/lib/src/version.ts +++ b/lib/src/version.ts @@ -8,4 +8,7 @@ export const version = '0.2.0'; */ export const clientType = 'web-sdk'; +/** + * Version of the opentdf/spec this library is targeting + */ export const tdfSpecVersion = '4.3.0'; diff --git a/lib/tdf3/src/index.ts b/lib/tdf3/src/index.ts index 8630c12f..11bc1855 100644 --- a/lib/tdf3/src/index.ts +++ b/lib/tdf3/src/index.ts @@ -1,4 +1,4 @@ export * as Client from './client/index.js'; export { Client as TDF3Client } from './client/index.js'; export * as Errors from '../../src/errors.js'; -export { version, clientType } from './version.js'; +export { clientType, tdfSpecVersion, version } from '../../src/version.js'; diff --git a/lib/tdf3/src/tdf.ts b/lib/tdf3/src/tdf.ts index fe4afd03..3bb99f79 100644 --- a/lib/tdf3/src/tdf.ts +++ b/lib/tdf3/src/tdf.ts @@ -4,7 +4,7 @@ import { DecoratedReadableStream } from './client/DecoratedReadableStream.js'; import { fetchKasPubKey as fetchKasPubKeyV2, fetchWrappedKey } from '../../src/access.js'; import { DecryptParams } from './client/builders.js'; import { AssertionConfig, AssertionKey, AssertionVerificationKeys } from './assertions.js'; -import { version } from './version.js'; +import { tdfSpecVersion } from '../../src/version.js'; import { hex } from '../../src/encodings/index.js'; import * as assertions from './assertions.js'; @@ -271,7 +271,7 @@ async function _generateManifest( // generate the manifest first, then insert integrity information into it encryptionInformation: encryptionInformationStr, assertions: assertions, - tdf_spec_version: version, + tdf_spec_version: tdfSpecVersion, }; } diff --git a/lib/tdf3/src/version.ts b/lib/tdf3/src/version.ts deleted file mode 100644 index 23724e9a..00000000 --- a/lib/tdf3/src/version.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const version = '4.3.0'; -export const clientType = 'tdf3-js-client'; diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 0969715e..0ef6956f 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -46,12 +46,7 @@ if ! sed_i "s/version=${old_version}/version=${new_version}/" "Makefile"; then exit 1 fi -if ! sed_i "s/export const version = '[^']\{1,\}';\$/export const version = \'${new_version}\';/" lib{,/tdf3}/src/version.ts; then - echo "Unable to change version in version files" - exit 1 -fi - -if ! sed_i "s/export const version = '[^']\{1,\}';\$/export const version = \'${new_version}\';/" lib{,/tdf3}/src/version.ts; then +if ! sed_i "s/export const version = '[^']\{1,\}';\$/export const version = \'${new_version}\';/" lib/src/version.ts; then echo "Unable to change version in version files" exit 1 fi diff --git a/scripts/check-version-is.sh b/scripts/check-version-is.sh index 650307ac..7f514e1f 100755 --- a/scripts/check-version-is.sh +++ b/scripts/check-version-is.sh @@ -16,16 +16,15 @@ if ! grep --fixed-strings --line-regexp --quiet "version=${expected_version}" "M exit 1 fi -for f in lib{,/tdf3}/src/version.ts; do - if ! grep --fixed-strings --line-regexp --quiet "export const version = '${expected_version}';" "$f"; then - if grep --quiet "^export const version" "$f"; then - echo "::error file=$f,line=$(sed -n '/export const version/=' $f)::Incorrect version line, should be setting it to [${expected_version}]" - else - echo "::error file=$f::Missing version line [version=${expected_version}]" - fi - exit 1 +f=lib/src/version.ts +if ! grep --fixed-strings --line-regexp --quiet "export const version = '${expected_version}';" "$f"; then + if grep --quiet "^export const version" "$f"; then + echo "::error file=$f,line=$(sed -n '/export const version/=' $f)::Incorrect version line, should be setting it to [${expected_version}]" + else + echo "::error file=$f::Missing version line [version=${expected_version}]" fi -done + exit 1 +fi for x in lib cli web-app; do sub_version="$(cd $x && node -p "require('./package.json').version")" @@ -36,7 +35,7 @@ for x in lib cli web-app; do done if [[ "${GITHUB_ACTION:-}" ]]; then - echo "TARGET_VERSION=$expected_version" >>$GITHUB_OUTPUT + echo "TARGET_VERSION=$expected_version" >>"$GITHUB_OUTPUT" else echo "SUCCESS: TARGET_VERSION=$expected_version" fi diff --git a/scripts/platform.sh b/scripts/platform.sh index 9c04e4ab..ee2216e9 100755 --- a/scripts/platform.sh +++ b/scripts/platform.sh @@ -12,4 +12,4 @@ if [ $? -ne 0 ]; then npm install @bufbuild/protoc-gen-es @bufbuild/buf @connectrpc/protoc-gen-connect-es fi npx buf generate platform/service -echo "Generated Typescript code from Protobuf files (src: platform/service, dst: lib/src/platform)" \ No newline at end of file +echo "Generated Typescript code from Protobuf files (src: platform/service, dst: lib/src/platform)"