Skip to content

Commit

Permalink
chore: add check-relase script as part of perversion validations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Apr 6, 2022
1 parent 794327f commit fe45c69
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Expand Up @@ -22,7 +22,6 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- run: |
yarn install --frozen-lockfile
yarn lint
- run: |
TAG=$(echo $GITHUB_REF_NAME | grep -oP '^v\d+\.\d+\.\d+-?\K(\w+)?')
npm publish --tag ${TAG:-latest}
Expand Down
22 changes: 21 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -57,4 +57,24 @@ The controller takes care of the following:
- try/catch RequestHandler method
- error handling with proper response code if they fail
- `await` the RequestHandler method if it returns a promise (so you don't have to)
- access control so that you can just list the required permission for a RequestHandler and the base Controller will make sure the user have these permissions.
- access control so that you can just list the required permission for a RequestHandler and the base Controller will make sure the user have these permissions.

## Creating a release
In order to produce a release you will need to be a Unleash core team member and have the Unleash admin role assigned on the Unleash organization on GitHub.

# Step 1: create a new version tag

Use npm to set the version in package.json and specify a version tag.

```sh
npm version 3.10.0
```

This command will trigger an internal verification step where we will perform the following steps:

- *STEP 1. Check unleash-frontend version* - Validate that a latest release of unleash-server does not depend on a pre-release of unleash-frontend (beta, alpha, etc)
- *STEP 2. Lint* - Run lint checks on the code.
- *STEP 3. Build* - Validate that we are able to build the project
- *STEP 4. Test* - Validate that all test runs green.

If all steps completes a single commit is produced on the main branch where the `version` property in package.json is updated, and a git tag is created to point to that tag specifically.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -45,7 +45,8 @@
"test:coverage:jest": "NODE_ENV=test PORT=4243 jest --silent --ci --json --coverage --testLocationInResults --outputFile=\"report.json\" --forceExit --testTimeout=10000",
"seed:setup": "ts-node src/test/e2e/seed/segment.seed.ts",
"seed:serve": "UNLEASH_DATABASE_NAME=unleash_test UNLEASH_DATABASE_SCHEMA=seed yarn run start:dev",
"clean": "del-cli --force dist"
"clean": "del-cli --force dist",
"preversion": "./scripts/check-release.sh $npm_package_version"
},
"jest": {
"automock": false,
Expand Down
29 changes: 29 additions & 0 deletions scripts/check-release.js
@@ -0,0 +1,29 @@
const semver = require('semver');
//@ts-ignore
const pck = require('../package.json');

const newUnleashVersion = process.argv[2];
const frontendVersion = pck.dependencies['unleash-frontend'];

function isPrerelease(version) {
const arr = semver.prerelease(version);
return arr && arr.length > 0;
}

if (!newUnleashVersion) {
console.error('You must provide the new Unleash version as argument');
process.exit(1);
}

if (!isPrerelease(newUnleashVersion)) {
if (isPrerelease(frontendVersion)) {
console.error(
`A latest version of unleash-server (${newUnleashVersion}) cannot depend on a pre-release of unleash-frontend (${frontendVersion})`,
);
process.exit(1);
}
}

console.log(
` Passed!\x1b[36m unleash-server v${newUnleashVersion}\x1b[0m can depend on\x1b[36m unleash-frontend v${frontendVersion}\x1b[0m`,
);
14 changes: 14 additions & 0 deletions scripts/check-release.sh
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

echo -e "\n STEP 1. Check unleash-frontend version"
node scripts/check-release.js $1

echo -e "\n STEP 2. Lint"
yarn run lint

echo -e "\n STEP 3. Build"
yarn run build

echo -e "\n STEP 4. Test"
yarn run test
3 changes: 2 additions & 1 deletion tsconfig.json
Expand Up @@ -76,6 +76,7 @@
"snapshots",
"coverage",
"website",
"setupJest.js"
"setupJest.js",
"scripts"
]
}

0 comments on commit fe45c69

Please sign in to comment.