diff --git a/.github/workflows/build-and-publish-asset.yml b/.github/workflows/build-and-publish-asset.yml index 99bcd7bd..83c91241 100644 --- a/.github/workflows/build-and-publish-asset.yml +++ b/.github/workflows/build-and-publish-asset.yml @@ -1,11 +1,15 @@ -name: Build and Publish Teraslice Asset -run-name: ${{ github.actor }} is building and publishing the Teraslice Asset +name: Build, Publish and Release Teraslice Asset +run-name: ${{ github.actor }} is building, publishing and releasing the Teraslice Asset on: workflow_dispatch: - release: - types: [published] + pull_request: + branches: + - master + types: + - closed jobs: call-asset-build: - uses: terascope/workflows/.github/workflows/asset-build-and-publish.yml@f86f716e47d989b939d978befa7721c1f5b10134 + if: github.event.pull_request.merged == true + uses: terascope/workflows/.github/workflows/asset-build-and-publish.yml@2f96a27a56e68c64c67b03d000672f41379e368e secrets: inherit diff --git a/package.json b/package.json index 0b8ac340..cd6a77b6 100644 --- a/package.json +++ b/package.json @@ -53,16 +53,20 @@ "@terascope/teraslice-state-storage": "~1.7.1", "@terascope/types": "~1.4.1", "@types/bluebird": "~3.5.42", + "@types/fs-extra": "~11.0.4", "@types/got": "~9.6.12", "@types/jest": "~29.5.14", "@types/node": "~22.10.6", + "@types/semver": "~7.5.8", "elasticsearch-store": "~1.7.2", "eslint": "~9.18.0", + "fs-extra": "~11.3.0", "jest": "~29.7.0", "jest-extended": "~4.0.2", "moment": "~2.30.1", "nock": "~13.5.6", "node-notifier": "~10.0.1", + "semver": "~7.6.3", "teraslice-test-harness": "~1.3.1", "ts-jest": "~29.2.5", "typescript": "~5.7.3" diff --git a/test/version-sync-spec.ts b/test/version-sync-spec.ts new file mode 100644 index 00000000..a6d109c9 --- /dev/null +++ b/test/version-sync-spec.ts @@ -0,0 +1,17 @@ +import path from 'node:path'; +import fse from 'fs-extra'; +import semver from 'semver'; + +describe('Ensure asset.json, package.json and root package.json versions are in sync', () => { + it('Versions are equal', () => { + const pathToAssetPkgJson = path.join(process.cwd(), './asset/package.json'); + const assetPkgJsonVersion = fse.readJSONSync(pathToAssetPkgJson).version; + const pathToAssetJson = path.join(process.cwd(), './asset/asset.json'); + const assetVersion = fse.readJSONSync(pathToAssetJson).version; + const pathToRootPkgJson = path.join(process.cwd(), './package.json'); + const rootVersion = fse.readJSONSync(pathToRootPkgJson).version; + + expect(semver.eq(assetPkgJsonVersion, rootVersion)).toBe(true); + expect(semver.eq(assetVersion, rootVersion)).toBe(true); + }); +}); diff --git a/yarn.lock b/yarn.lock index 6255d4b3..c2a0d9f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1695,6 +1695,16 @@ __metadata: languageName: node linkType: hard +"@types/fs-extra@npm:~11.0.4": + version: 11.0.4 + resolution: "@types/fs-extra@npm:11.0.4" + dependencies: + "@types/jsonfile": "npm:*" + "@types/node": "npm:*" + checksum: 10c0/9e34f9b24ea464f3c0b18c3f8a82aefc36dc524cc720fc2b886e5465abc66486ff4e439ea3fb2c0acebf91f6d3f74e514f9983b1f02d4243706bdbb7511796ad + languageName: node + linkType: hard + "@types/geojson@npm:^7946.0.10, @types/geojson@npm:^7946.0.14": version: 7946.0.14 resolution: "@types/geojson@npm:7946.0.14" @@ -1778,6 +1788,15 @@ __metadata: languageName: node linkType: hard +"@types/jsonfile@npm:*": + version: 6.1.4 + resolution: "@types/jsonfile@npm:6.1.4" + dependencies: + "@types/node": "npm:*" + checksum: 10c0/b12d068b021e4078f6ac4441353965769be87acf15326173e2aea9f3bf8ead41bd0ad29421df5bbeb0123ec3fc02eb0a734481d52903704a1454a1845896b9eb + languageName: node + linkType: hard + "@types/keyv@npm:^3.1.4": version: 3.1.4 resolution: "@types/keyv@npm:3.1.4" @@ -1830,6 +1849,13 @@ __metadata: languageName: node linkType: hard +"@types/semver@npm:~7.5.8": + version: 7.5.8 + resolution: "@types/semver@npm:7.5.8" + checksum: 10c0/8663ff927234d1c5fcc04b33062cb2b9fcfbe0f5f351ed26c4d1e1581657deebd506b41ff7fdf89e787e3d33ce05854bc01686379b89e9c49b564c4cfa988efa + languageName: node + linkType: hard + "@types/stack-utils@npm:^2.0.0": version: 2.0.3 resolution: "@types/stack-utils@npm:2.0.3" @@ -3464,16 +3490,20 @@ __metadata: "@terascope/teraslice-state-storage": "npm:~1.7.1" "@terascope/types": "npm:~1.4.1" "@types/bluebird": "npm:~3.5.42" + "@types/fs-extra": "npm:~11.0.4" "@types/got": "npm:~9.6.12" "@types/jest": "npm:~29.5.14" "@types/node": "npm:~22.10.6" + "@types/semver": "npm:~7.5.8" elasticsearch-store: "npm:~1.7.2" eslint: "npm:~9.18.0" + fs-extra: "npm:~11.3.0" jest: "npm:~29.7.0" jest-extended: "npm:~4.0.2" moment: "npm:~2.30.1" nock: "npm:~13.5.6" node-notifier: "npm:~10.0.1" + semver: "npm:~7.6.3" teraslice-test-harness: "npm:~1.3.1" ts-jest: "npm:~29.2.5" typescript: "npm:~5.7.3" @@ -4507,6 +4537,17 @@ __metadata: languageName: node linkType: hard +"fs-extra@npm:~11.3.0": + version: 11.3.0 + resolution: "fs-extra@npm:11.3.0" + dependencies: + graceful-fs: "npm:^4.2.0" + jsonfile: "npm:^6.0.1" + universalify: "npm:^2.0.0" + checksum: 10c0/5f95e996186ff45463059feb115a22fb048bdaf7e487ecee8a8646c78ed8fdca63630e3077d4c16ce677051f5e60d3355a06f3cd61f3ca43f48cc58822a44d0a + languageName: node + linkType: hard + "fs-minipass@npm:^3.0.0": version: 3.0.3 resolution: "fs-minipass@npm:3.0.3"