Socket
Socket
Sign inDemoInstall

github-release-from-changelog

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-release-from-changelog - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

yarn.lock

29

CHANGELOG.md

@@ -0,8 +1,15 @@

# 1.3.0 - 2017-12-06
* [Add support for auto-determing different CHANGELOG filenames](https://github.com/MoOx/github-release-from-changelog/commit/eb8f20855810201561144ca3762168d1da421d12),
by @koppor, reported by @MoOx (in [#6](https://github.com/MoOx/github-release-from-changelog/issues/6))
* [Add support for format of "Keep a Changelog"](https://github.com/MoOx/github-release-from-changelog/commit/cf50e4e8f0829c36eb837974e189d733fdb0effd),
by @koppor
# 1.2.1 - 2016-06-28
- Fixed: ``Empty value for parameter 'tag_name': undefined``
* Fixed: `Empty value for parameter 'tag_name': undefined`
# 1.2.0 - 2016-06-28
- Changed: use ``grizzly`` v2.x
* Changed: use `grizzly` v2.x
(ref [node-grizzly#1](https://github.com/coderaiser/node-grizzly/issues/1))

@@ -12,4 +19,4 @@

- Fixed: ``TypeError: Cannot read property 'createRelease' of undefined``
by fixing ``grizzly`` version.
* Fixed: `TypeError: Cannot read property 'createRelease' of undefined`
by fixing `grizzly` version.
([#12](https://github.com/MoOx/npmpub/issues/12))

@@ -19,19 +26,19 @@

- Fixed: `chmod +x ./github-release-from-changelog.js`
* Fixed: `chmod +x ./github-release-from-changelog.js`
# 1.1.2 - 2016-02-12
- Fixed: tag starting with "v" are now compatible.
([#9](https://github.com/MoOx/github-release-from-changelog/pull/9))
* Fixed: tag starting with "v" are now compatible.
([#9](https://github.com/MoOx/github-release-from-changelog/pull/9))
# 1.1.1 - 2016-01-06
- Fixed: blank line are not stripped for block anymore (which can break
* Fixed: blank line are not stripped for block anymore (which can break
markdown rendering - eg: title using `##` )
([#7](https://github.com/MoOx/github-release-from-changelog/pull/7))
([#7](https://github.com/MoOx/github-release-from-changelog/pull/7))
# 1.1.0 - 2015-11-10
- Added: `--filename` option to specify your own filename
(if you don't use `CHANGELOG.md`).
* Added: `--filename` option to specify your own filename
(if you don't use `CHANGELOG.md`).

@@ -38,0 +45,0 @@ # 1.0.0 - 2015-10-04

@@ -19,81 +19,128 @@ #!/usr/bin/env node

var token = process.env.GITHUB_TOKEN
var token = process.env.GITHUB_TOKEN;
if (!token) {
throw "GITHUB_TOKEN required"
throw "GITHUB_TOKEN required";
}
// read command line arguments
var cp = require('child_process');
var minimist = require('minimist');
var cp = require("child_process");
var minimist = require("minimist");
var argv = minimist(process.argv.slice(2));
var fs = require("fs");
// changelog file name
var changelogFileName = argv.filename || "CHANGELOG.md";
var changelogFileName = argv.filename;
if (!changelogFileName) {
const changelogFileNames = [
"CHANGELOG.md",
"Changelog.md",
"changelog.md",
"CHANGES.md",
"Changes.md",
"changes.md",
"HISTORY.md",
"History.md",
"history.md",
"NEWS.md",
"News.md",
"news.md",
"RELEASES.md",
"Releases.md",
"releases.md"
];
for (var fileName of changelogFileNames) {
if (fs.existsSync(fileName)) {
changelogFileName = fileName;
break;
}
}
}
// console.log("changelog filename", changelogFileName);
// get dep
var release = require("grizzly")
var release = require("grizzly");
// read package.json
var pkg
var pkg;
try {
pkg = require(process.cwd() + "/package.json")
pkg = require(process.cwd() + "/package.json");
} catch (e) {
throw "No package.json found in " + process.cwd();
}
catch(e) {throw "No package.json found in " + process.cwd()}
// read changelog
var changelog
var changelog;
try {
changelog = require("fs").readFileSync(process.cwd() + "/" + changelogFileName, {encoding: "utf8"})
changelog = fs.readFileSync(process.cwd() + "/" + changelogFileName, {
encoding: "utf8"
});
} catch (e) {
throw "No " + changelogFileName + " found in " + process.cwd();
}
catch(e) {throw "No " + changelogFileName + " found in " + process.cwd()}
// parse repository url to get user & repo slug
var repoUrl
repoUrl = pkg.repository
var repoUrl;
repoUrl = pkg.repository;
if (repoUrl === undefined) {
throw "No repository.url found in " + process.cwd() + "/repository(.url)"
throw "No repository.url found in " + process.cwd() + "/repository(.url)";
}
if (typeof repoUrl === "object" && repoUrl.url) {
repoUrl = repoUrl.url
repoUrl = repoUrl.url;
}
var matches = repoUrl.match(/(?:https?|git(?:\+ssh)?)(?::\/\/)(?:www\.)?github\.com\/(.*)/i)
var matches = repoUrl.match(
/(?:https?|git(?:\+ssh)?)(?::\/\/)(?:www\.)?github\.com\/(.*)/i
);
if (matches === null) {
throw "Unable to parse repository url"
throw "Unable to parse repository url";
}
var repoData = matches[1].split("/")
var user = repoData[0]
var repo = repoData[1].replace(/\.git$/, "")
var repoData = matches[1].split("/");
var user = repoData[0];
var repo = repoData[1].replace(/\.git$/, "");
// version
var version = pkg.version
var version = pkg.version;
// Look for the tag in either X.Y.Z or vX.Y.X formats
var tags = cp.execSync("git tag", {encoding: 'utf8'})
var tagMatches = tags.match(new RegExp("^(v?)" + version + "$", "gm"))
var tagName
var tags = cp.execSync("git tag", { encoding: "utf8" });
var tagMatches = tags.match(new RegExp("^(v?)" + version + "$", "gm"));
var tagName;
if (tagMatches === null) {
throw "Tag " + version + " or v" + version + " not found"
throw "Tag " + version + " or v" + version + " not found";
} else {
tagName = tagMatches[0]
tagName = tagMatches[0];
}
// changelog
var body = []
var start
var body = [];
var start;
const changelogLines = changelog.replace(/\r\n/g, "\n").split("\n");
// determine whether the log format of http://keepachangelog.com/en/1.0.0/: check the first line and check if there is a second level heading linking to the version diff
const isKeepAChangelogFormat =
changelogLines[0] === "# Changelog" &&
changelog.indexOf("\n## [" + version + "]") !== -1;
// console.log(isKeepAChangelogFormat);
// read from # version to the next # .*
changelog.split("\n").some(function(line, i) {
changelogLines.some(function(line, i) {
// start with the # version
if (!start && line.indexOf("# " + version) === 0) {
start = true
if (
!start &&
(line.indexOf("# " + version) === 0 ||
(isKeepAChangelogFormat && line.indexOf("## [") === 0))
) {
start = true;
} else if (
start &&
(line.indexOf("# ") === 0 ||
(isKeepAChangelogFormat && line.indexOf("## [") === 0))
) {
// end with another # version
return true;
} else if (start) {
// between start & end, collect lines
body.push(line);
}
// end with another # version
else if (start && line.indexOf("# ") === 0) {
return true
}
// between start & end, collect lines
else if (start) {
body.push(line)
}
})
body = body.join("\n")
});
body = body.join("\n").trim();

@@ -107,3 +154,3 @@ // prepare release data

body: body
}
};

@@ -114,5 +161,5 @@ // console.log("About to release ", releaseOptions)

if (err) {
throw err
throw err;
}
console.log(user + "/" + repo + " " + tagName + " released")
})
console.log(user + "/" + repo + " " + tagName + " released");
});
{
"name": "github-release-from-changelog",
"version": "1.2.1",
"version": "1.3.0",
"description": "Create GitHub releases from CHANGELOG.md",

@@ -13,3 +13,6 @@ "keywords": [

"github",
"release"
"release",
"release notes",
"changelog",
"history"
],

@@ -27,8 +30,17 @@ "author": "Maxime Thirouin",

"devDependencies": {
"npmpub": "^3.0.1"
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"npmpub": "^3.0.1",
"prettier": "^1.9.1"
},
"scripts": {
"precommit": "lint-staged",
"format": "prettier --write \"**/*.{js,json,css,md}\"",
"test": "echo \"I use myself\"",
"release": "npmpub --no-release && ./github-release-from-changelog.js"
"release": "npmpub --no-release",
"postrelease": "./github-release-from-changelog.js"
},
"lint-staged": {
"*.{js,json,css,md}": ["prettier --write", "git add"]
}
}

@@ -1,2 +0,2 @@

# github-release-from-changelog
# github-release-from-changelog [![NPM version](https://img.shields.io/npm/v/github-release-from-changelog.svg?style=flat)](https://www.npmjs.com/package/github-release-from-changelog)

@@ -7,7 +7,6 @@ > Create GitHub releases from CHANGELOG.md

---
You need:
- a CHANGELOG with the following format:
* a CHANGELOG following the format of [keep a changelog](http://keepachangelog.com/en/1.0.0/) or a CHANGELOG with the following format:
```md

@@ -18,7 +17,8 @@ # X.Y.Z - ...

```
- a `package.json` with a `version` field
- a git tag with the corresponding version in either `X.Y.Z` or `vX.Y.Z` formats
- a `GITHUB_TOKEN` as an env var
This plugin edit the git tag on GitHub and create a GitHub release with the
* a `package.json` with a `version` field
* a git tag with the corresponding version in either `X.Y.Z` or `vX.Y.Z` formats
* a `GITHUB_TOKEN` as an env var
This tool edit the git tag on GitHub and create a GitHub release with the
correct CHANGELOG.md section.

@@ -28,5 +28,5 @@

```console
npm install github-release-from-changelog
```
$ npm install github-release-from-changelog
```

@@ -36,3 +36,3 @@ ## Usage

```console
$ github-release-from-changelog [--filename CustomChangelog.md]
github-release-from-changelog [--filename CustomChangelog.md]
```

@@ -39,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc