-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f985b9c
commit e4a1a91
Showing
7 changed files
with
756 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
.vscode | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Changelog | ||
|
||
## v1.0.0-beta.3 (2019-10-01) | ||
|
||
### Features | ||
|
||
* add interface body getter to std err ([#192](https://github.com/scaleway/scaleway-sdk-go/pull/192)) | ||
* add support for out of stock error ([#190](https://github.com/scaleway/scaleway-sdk-go/pull/190)) | ||
* use uint32 for page count ([#193](https://github.com/scaleway/scaleway-sdk-go/pull/193)) | ||
* add raw body to standard errors ([#191](https://github.com/scaleway/scaleway-sdk-go/pull/191)) | ||
* update generated apis ([#188](https://github.com/scaleway/scaleway-sdk-go/pull/188)) | ||
|
||
### Fixes | ||
|
||
* e2e tests project ([#195](https://github.com/scaleway/scaleway-sdk-go/pull/195)) | ||
* **instance**: allow image to be empty in CreateServer ([#189](https://github.com/scaleway/scaleway-sdk-go/pull/189)) | ||
|
||
|
||
## v1.0.0-beta.2 (2019-09-16) | ||
|
||
### Features | ||
|
||
* test standard errors ([#183](https://github.com/scaleway/scaleway-sdk-go/pull/183)) | ||
* update generated apis ([#182](https://github.com/scaleway/scaleway-sdk-go/pull/182)) | ||
* standard error structures ([#177](https://github.com/scaleway/scaleway-sdk-go/pull/177)) | ||
|
||
### Fixes | ||
|
||
* attach volume key choice ([#184](https://github.com/scaleway/scaleway-sdk-go/pull/184)) | ||
* add user agent to e2e tests ([#181](https://github.com/scaleway/scaleway-sdk-go/pull/181)) | ||
* update version ([#180](https://github.com/scaleway/scaleway-sdk-go/pull/180)) | ||
* UpdateSecurityGroupRule can now remove DestPortFrom and DestPortTo ([#179](https://github.com/scaleway/scaleway-sdk-go/pull/179)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Scaleway GO SDK - Scripts | ||
|
||
This directory contains useful scripts to work on scaleway-go-sdk. | ||
|
||
### check_for_tokens.sh \*\* | ||
|
||
Checks that no token are present in cassette file | ||
|
||
``` | ||
Usage: ./script/check_for_tokens.sh | ||
``` | ||
|
||
### release.sh \*\* | ||
|
||
This script will trigger the release process. | ||
For more information on the release process you can refer to ./release/release.js file | ||
|
||
``` | ||
Usage: ./script/release.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
cd scripts/release || (echo "Please run this script from repo root" && exit 1) | ||
|
||
yarn install --frozen-lock-file | ||
yarn run release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "scripts", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"colors": "^1.4.0", | ||
"get-stream": "^5.1.0", | ||
"git-raw-commits": "^2.0.2", | ||
"semver": "^6.3.0" | ||
}, | ||
"scripts": { | ||
"release": "node release.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
/****************************************************************************** | ||
* Scaleway GO SDK release script. | ||
* | ||
* This script will trigger a release process for the scaleway Go SDK. | ||
* | ||
* The script will proceed as follow: | ||
* - Create a new remote `scaleway-release` that point to main repo | ||
* - Prompt the new version number | ||
* - Create release commit | ||
* - Generate a changelog | ||
* - Update version in scw/version.go | ||
* - Ask to review changes | ||
* - Ask to merge this changes to master via PR | ||
* - Create a github release | ||
* - Ask to create a github release | ||
* - Create a post release commit | ||
* - Update scw/version.go to add +dev at the end | ||
* - Ask to merge this changes to master via PR | ||
* - Delete temporary remote `scaleway-release` that was created earlier | ||
******************************************************************************/ | ||
|
||
const { spawnSync } = require("child_process"), | ||
readline = require("readline"), | ||
fs = require("fs") | ||
; | ||
|
||
const gitRawCommits = require("git-raw-commits"), | ||
semver = require("semver"), | ||
getStream = require("get-stream"), | ||
_ = require("colors") | ||
; | ||
|
||
const _typeReg = /(?<type>[a-zA-Z]+)/; | ||
const _scopeReg = /(\((?<scope>.*)\))?/; | ||
const _messageReg = /(?<message>[^(]*)/; | ||
const _mrReg = /(\(#(?<mr>[0-9]+)\))?/; | ||
const COMMIT_REGEX = new RegExp(`${_typeReg.source}${_scopeReg.source}: *${_messageReg.source} *${_mrReg.source}`); | ||
const CHANGELOG_PATH = "../../CHANGELOG.md"; | ||
const GO_VERSION_PATH = "../../scw/version.go"; | ||
const TMP_BRANCH = "new-release"; | ||
const TMP_REMOTE = "scaleway-release"; | ||
const REPO_URL = "[email protected]:scaleway/scaleway-sdk-go.git"; | ||
|
||
async function main() { | ||
|
||
// | ||
// Initialization | ||
// | ||
console.log("Adding temporary remote on local repo".blue); | ||
git( "remote", "add", TMP_REMOTE, REPO_URL); | ||
console.log(` Successfully created ${TMP_REMOTE} remote`.green); | ||
|
||
console.log("Make sure we are working on an up to date master".blue); | ||
git( "fetch", TMP_REMOTE); | ||
git( "checkout", `${TMP_REMOTE}/master`); | ||
console.log(` Successfully created ${TMP_REMOTE} remote`.green); | ||
|
||
console.log("Trying to find last release tag".blue); | ||
const lastSemverTag = git("tag") | ||
.trim() | ||
.split("\n") | ||
.filter(semver.valid) | ||
.sort((a, b) => semver.rcompare(semver.clean(a), semver.clean(b)))[0]; | ||
console.log(` Last found release tag was ${lastSemverTag}`.green); | ||
|
||
console.log("Listing commit since last release".blue); | ||
const commits = (await getStream.array(gitRawCommits({ from: lastSemverTag, format: "%s" }))).map(c => c.toString().trim()); | ||
commits.forEach(c => console.log(` ${c}`.grey)); | ||
console.log(` We found ${commits.length} commits since last release`.green); | ||
|
||
const newVersion = semver.clean(await prompt("Enter new version: ".magenta)); | ||
if (!newVersion) { | ||
throw new Error(`invalid version`); | ||
} | ||
|
||
// | ||
// Creating release commit | ||
// | ||
|
||
console.log(`Updating ${CHANGELOG_PATH} and ${GO_VERSION_PATH}`.blue); | ||
// Generate changelog lines by section | ||
const changelogLines = { feat: [], fix: [] }; | ||
commits.forEach(commit => { | ||
const result = COMMIT_REGEX.exec(commit); | ||
if (!result || !(result.groups.type in changelogLines)) { | ||
console.warn(`WARNING: Ignoring commit ${commit}`.yellow); | ||
return; | ||
} | ||
const stdCommit = result.groups; | ||
|
||
let line = [`*`, stdCommit.scope ? `**${stdCommit.scope}**:` : "", stdCommit.message, stdCommit.mr ? `([#${stdCommit.mr}](https://github.com/scaleway/scaleway-sdk-go/pull/${stdCommit.mr}))` : ""] | ||
.map(s => s.trim()) | ||
.filter(v => v) | ||
.join(" "); | ||
changelogLines[stdCommit.type].push(line); | ||
}); | ||
|
||
const changelogHeader = `## v${newVersion} (${new Date().toISOString().substring(0, 10)})`; | ||
const changelogSections = []; | ||
if (changelogLines.feat) { | ||
changelogSections.push("### Features\n\n" + changelogLines.feat.join("\n")); | ||
} | ||
if (changelogLines.fix) { | ||
changelogSections.push("### Fixes\n\n" + changelogLines.fix.join("\n")); | ||
} | ||
const changelogBody = changelogSections.join("\n\n"); | ||
const changelog = `${changelogHeader}\n\n${changelogBody}`; | ||
|
||
replaceInFile(CHANGELOG_PATH, "# Changelog", "# Changelog\n\n" + changelog + "\n"); | ||
replaceInFile(GO_VERSION_PATH, /const version[^\n]*\n/, `const version = "v${newVersion}"\n`); | ||
console.log(` Update success`.green); | ||
|
||
await prompt(`Please review ${CHANGELOG_PATH} and ${GO_VERSION_PATH}. When everything is fine hit enter to continue ...`.magenta); | ||
|
||
console.log(`Creating release commit`.blue); | ||
git("checkout", "-b", TMP_BRANCH); | ||
git("add", CHANGELOG_PATH, GO_VERSION_PATH); | ||
git("commit", "-m", `chore: release ${newVersion}`); | ||
git("push", "-f", "--set-upstream", TMP_REMOTE, TMP_BRANCH); | ||
|
||
await prompt(`Please create an PR here: https://github.com/scaleway/scaleway-sdk-go/pull/new/new-release . Hit enter when its merged .....`.magenta); | ||
|
||
console.log("Time to create a github release with the following info\n".blue); | ||
console.log(`Title: v${newVersion}\n\n`.gray); | ||
console.log(`${changelogBody}\n\n`.gray); | ||
await prompt(`You should create a new github release here: https://github.com/scaleway/scaleway-sdk-go/releases/new/ . Hit enter when the new release is created .....`.magenta); | ||
|
||
// | ||
// Creating post release commit | ||
// | ||
console.log("Make sure we pull the latest commit from master".blue); | ||
git("fetch", TMP_REMOTE); | ||
git("checkout", `${TMP_REMOTE}/master`); | ||
console.log(" Successfully checkout upstream/master".green); | ||
|
||
console.log(`Creating post release commit`.blue); | ||
git("branch", "-D", TMP_BRANCH); | ||
git("checkout", "-b", TMP_BRANCH); | ||
replaceInFile(GO_VERSION_PATH, /const version[^\n]*\n/, `const version = "v${newVersion}+dev"\n`); | ||
git("add", GO_VERSION_PATH); | ||
git("commit", "-m", "chore: post release commit"); | ||
git("push", "-f", "--set-upstream", TMP_REMOTE, TMP_BRANCH); | ||
git("checkout", "master"); | ||
git("branch", "-D", TMP_BRANCH); | ||
await prompt(`Please create an PR here: https://github.com/scaleway/scaleway-sdk-go/pull/new/new-release . Hit enter when its merged .....`.magenta); | ||
|
||
console.log("Make sure we pull the latest commit from master".blue); | ||
git("pull", TMP_REMOTE, "master"); | ||
console.log(" Successfully pull master".green); | ||
|
||
console.log("Remove temporary remote".blue); | ||
git("remote", "remove", TMP_REMOTE); | ||
console.log(" Successfully remove temporary remote".green); | ||
|
||
console.log(`🚀 Release Success `.green); | ||
} | ||
|
||
function git(...args) { | ||
console.log(` git ${args.join(" ")}`.grey); | ||
const { stdout, status, stderr } = spawnSync("git", args, { encoding: "utf8" }); | ||
if (status !== 0) { | ||
throw new Error(`return status ${status}\n${stderr}\n`); | ||
} | ||
return stdout; | ||
} | ||
|
||
function replaceInFile(path, oldStr, newStr) { | ||
console.log(` Editing ${path}`.grey); | ||
const content = fs.readFileSync(path, { encoding: "utf8" }).replace(oldStr, newStr); | ||
fs.writeFileSync(path, content); | ||
} | ||
|
||
function prompt(prompt) { | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
return new Promise(resolve => { | ||
rl.question(prompt, answer => { | ||
resolve(answer); | ||
rl.close(); | ||
}); | ||
}); | ||
} | ||
|
||
main().catch(console.error); |
Oops, something went wrong.