Skip to content

Commit

Permalink
Automate release (#1344)
Browse files Browse the repository at this point in the history
This PR makes the following changes:
- Update `build-and-publish-asset.yml` workflow to run on all merges to
master. The workflow it triggers will now create a release, build and
publish if the asset version has been bumped.
- Add test to ensure versions in `asset/asset.json`,
`asset/package.json`, and `package.json` stay synced.
  • Loading branch information
busma13 authored Jan 16, 2025
1 parent d5edd70 commit b1a1963
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/build-and-publish-asset.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions test/version-sync-spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
41 changes: 41 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b1a1963

Please sign in to comment.