@aircall/ci-scripts
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -8,3 +8,5 @@ #!/usr/bin/env node | ||
getLatestRelease, | ||
getLatestReleasedTag | ||
getLatestReleasedTag, | ||
getPreviousRelease, | ||
getPreviousReleaseFromSha1 | ||
} = require('./github.js'); | ||
@@ -46,2 +48,5 @@ const { | ||
} | ||
if (usefullArguments.includes('--from-circle-ci-sha1')) { | ||
options.fromCircleCISha1 = true; | ||
} | ||
if (usefullArguments.includes('--from-prerelease')) { | ||
@@ -177,2 +182,12 @@ options.fromPreRelease = true; | ||
case 'previous_version': | ||
const previousRelease = options.fromCircleCISha1 | ||
? await getPreviousReleaseFromSha1() | ||
: await getPreviousRelease(); | ||
console.log( | ||
!!previousRelease ? previousRelease.tag_name : 'No previous releases created yet' | ||
); | ||
break; | ||
case 'changelog': | ||
@@ -233,3 +248,3 @@ const changelogData = await diffData(); | ||
case 'notify-slack': | ||
const [env, channel, title] = usefullArguments.slice(1,4); | ||
const [env, channel, title] = usefullArguments.slice(1, 4); | ||
if (!(env && channel)) { | ||
@@ -236,0 +251,0 @@ throw new Error('notify-slack command needs arguments <env> and <channel>'); |
@@ -111,2 +111,10 @@ const { get, patch, post } = require('./request.js'); | ||
const getPreviousReleaseFromSha1 = async commitish => { | ||
const releases = await getReleases(); | ||
const release = releases.findIndex(r => { | ||
return r.target_commitish === commitish; | ||
}); | ||
return release[index + 1]; | ||
}; | ||
const executeGraphQLRequest = async query => { | ||
@@ -210,3 +218,4 @@ const { data } = await post(githubGraphQLUrl, { | ||
getReleaseFromSha1, | ||
getPreviousReleaseFromRelease | ||
getPreviousReleaseFromRelease, | ||
getPreviousReleaseFromSha1 | ||
}; |
{ | ||
"name": "@aircall/ci-scripts", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"dependencies": {}, | ||
@@ -5,0 +5,0 @@ "main": "ci-scripts.js", |
@@ -74,11 +74,13 @@ # CI Scripts | ||
You'll need to pass your Github credentials to run a command. Those credentials are formatted as `username:access_token`. | ||
You'll need to pass your Github credentials to run a command. Those credentials are formatted as `username:access_token`. | ||
To generate a new access token: | ||
* in Github, go to the Settings page and then in the Developer settings section | ||
* then in Personal access tokens, you can generate a new access token. You only have to select the `repo` scope. | ||
- in Github, go to the Settings page and then in the Developer settings section | ||
- then in Personal access tokens, you can generate a new access token. You only have to select the `repo` scope. | ||
#### Link your project to ci-scripts | ||
For your project to use the local `ci-scripts` project, you must: | ||
- from the `ci-scripts` project, run `npm link` | ||
@@ -92,7 +94,8 @@ - from your project, run `npm link ci-scripts` | ||
To fetch the version of the latest release of the phone, call the `latest_version` command with the correct variables: | ||
* `CIRCLE_PROJECT_USERNAME`: aircall | ||
* `CIRCLE_PROJECT_REPONAME`: the project for which you want to retrieve the latest release version | ||
* `GITHUB_CREDENTIALS`: concatenation of your Github username and your personal access token | ||
* `JIRA_BASE_URL`: aircall Jira base url | ||
- `CIRCLE_PROJECT_USERNAME`: aircall | ||
- `CIRCLE_PROJECT_REPONAME`: the project for which you want to retrieve the latest release version | ||
- `GITHUB_CREDENTIALS`: concatenation of your Github username and your personal access token | ||
- `JIRA_BASE_URL`: aircall Jira base url | ||
``` | ||
@@ -186,2 +189,20 @@ CIRCLE_PROJECT_USERNAME=aircall CIRCLE_PROJECT_REPONAME=phone GITHUB_CREDENTIALS=litil:access_token JIRA_BASE_URL=https://aircall.atlassian.net ci-scripts latest_version | ||
### Get the latest version based on the releases (display only) | ||
```js | ||
npx ci-scripts latest_version | ||
``` | ||
### Get the previous version based on the releases (display only) | ||
```js | ||
npx ci-scripts previous_version | ||
``` | ||
additionally you can pass a flag to get the relative previous release from the current one based on the `CIRCLE_SHA1` value | ||
```js | ||
npx ci-scripts previous_version --from-circle-ci-sha1 | ||
``` | ||
### Post a Slack Deployment Notification | ||
@@ -188,0 +209,0 @@ |
35182
901
231