Skip to content

Commit

Permalink
Use jbash package
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt committed Aug 22, 2017
1 parent e32dda0 commit 4bc214b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion RELEASING.md
Expand Up @@ -6,7 +6,7 @@
The following instructions are for building, packaging and releasing the library to NuGet.

1. Ensure [.NET Core SDK](https://www.microsoft.com/net/download/core#/sdk) version >= 2.0.0 is installed
2. Ensure Node.js version >= 4 is installed and that shelljs js npm package is installed globally (`npm install -g shelljs`).
2. Ensure Node.js version >= 4 is installed and that jBash is installed globally (`npm i -g jbash`).
3. Ensure `NUGET_API_KEY` and `GITHUB_API_TOKEN` environment variables are set
4. Run the `scripts/release.js` command, passing in the version and release notes:

Expand Down
30 changes: 12 additions & 18 deletions scripts/release.js
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/local/bin/jbash

/* Releases CronExpressionDescriptor
This includes: running tests, building in release mode, signing, packaging, publishing on
Expand All @@ -7,12 +7,6 @@
Example:
release.sh 2.0.0 "Fixed DOW bug causing exception" */

// jsbash
_p = process; args = _p.argv.slice(2); cd = _p.chdir; exit = _p.exit; env = _p.env; echo = console.log;
_e = "utf-8"; _fs = require("fs"); readFile = (path, encoding = _e) => { return _fs.readFileSync(path, { encoding }) }; writeFile = (path, contents, encoding = _e) => { _fs.writeFileSync(path, contents, { encoding }) };
$$ = (cmd, stream) => { r = (require("child_process").execSync(cmd, { stdio: stream ? "inherit" : "pipe" }) ); return !!r ? r.toString().replace(/^\n$/, "") : null; };
$ = cmd => { return $(cmd, true); };

// cd to root dir
cd(`${__dirname}/../`);

Expand All @@ -24,7 +18,7 @@ Example:
exit(1);
}

if ($$(`git status --porcelain`)) {
if ($(`git status --porcelain`)) {
echo(`All changes must be committed first.`);
exit(1);
}
Expand All @@ -38,8 +32,8 @@ let nupkgFile = `CronExpressionDescriptor.${version}.nupkg`;
let libCsproj = "lib/CronExpressionDescriptor.csproj";
let ghRepo = "bradyholt/cron-expression-descriptor";

$(`dotnet restore`);
$(`dotnet test -c release test/Test.csproj`);
eval(`dotnet restore`);
eval(`dotnet test -c release test/Test.csproj`);

// Update CronExpressionDescriptor.csproj with version and release notes
let csProj = readFile(libCsproj);
Expand All @@ -54,27 +48,27 @@ csProj = csProj.replace(
writeFile(libCsproj, csProj);

// Build, pack, and push to NuGet
$(`dotnet build -c release -p:SignAssembly=True,PublicSign=True ${libCsproj}`);
$(`dotnet pack -c release --no-build ${libCsproj}`);
$(`dotnet nuget push ${releasePath}/${nupkgFile} -k ${env.NUGET_API_KEY}`);
eval(`dotnet build -c release -p:SignAssembly=True,PublicSign=True ${libCsproj}`);
eval(`dotnet pack -c release --no-build ${libCsproj}`);
eval(`dotnet nuget push ${releasePath}/${nupkgFile} -k ${env.NUGET_API_KEY}`);

// Commit changes to project file
$(`git commit -am "New release: ${version}"`);
eval(`git commit -am "New release: ${version}"`);

// Create release tag
$(`git tag -a ${version} -m "${notes}"`);
$(`git push --tags`);
eval(`git tag -a ${version} -m "${notes}"`);
eval(`git push --tags`);

// Create release on GitHub
let response = $$(`curl -f -H "Authorization: token ${env.GITHUB_API_TOKEN}" \
let response = $(`curl -f -H "Authorization: token ${env.GITHUB_API_TOKEN}" \
-d '{"tag_name":"${version}", "name":"${version}","body":"${notes}","prerelease": ${preRelease}}' \
https://api.github.com/repos/${ghRepo}/releases`
);

let releaseId = JSON.parse(response).id;

// Get the release id and then upload the and upload the .nupkg
$(`curl -H "Authorization: token ${env.GITHUB_API_TOKEN}" -H "Content-Type: application/octet-stream" \
eval(`curl -H "Authorization: token ${env.GITHUB_API_TOKEN}" -H "Content-Type: application/octet-stream" \
--data-binary @"${releasePath}/${nupkgFile}" \
https://uploads.github.com/repos/${ghRepo}/releases/${releaseId}/assets?name=${nupkgFile}`);

Expand Down

0 comments on commit 4bc214b

Please sign in to comment.