2.0.0 • Published 3 years ago
octokit-plugin-get-semantic-releases v2.0.0
octokit-plugin-get-semantic-releases
Get repository releases with semantic version tags (e.g.
v1.2.3
,v2.0.0-beta.1
, etc)
usage
Browsers
Load octokit-plugin-get-semantic-releases
and @octokit/core
(or core-compatible module) directly from cdn.skypack.dev
<script type="module">
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
import {
getSemanticReleases,
composeGetSemanticReleases,
} from "https://cdn.skypack.dev/octokit-plugin-get-semantic-releases";
</script>
Node
Install with npm install @octokit/core octokit-plugin-get-semantic-releases
. Optionally replace @octokit/core
with a compatible module
const { Octokit } = require("@octokit/core");
const {
getSemanticReleases,
composeGetSemanticReleases,
} = require("octokit-plugin-get-semantic-releases");
const MyOctokit = Octokit.plugin(getSemanticReleases);
const octokit = new MyOctokit({ auth: "secret123" });
const releases = await octokit.getSemanticReleases({
owner: "octokit",
repo: "core.js",
});
// `releases` is array of releases as shown at https://docs.github.com/en/rest/reference/releases#list-releases
// but includes a `version` property, which is the normalized semantic version derived from the tag name.
// The releases are sorted by version in ascending order.
If you want to utilize the getSemanticReleases()
in another plugin or with an existing octokit
instance, use composeGetSemanticReleases
.
function myPlugin(octokit, options) {
return {
myMethod({owner, repo}) => {
return composeGetSemanticReleases(
octokit,
{owner, repo }
)
}
}
}
Options
Filter out versions that don't match the range
string following semver conventions.
Example: Load all stable versions greater than v1.2.1
but not inclusive.
const releases = await octokit.getSemanticReleases({
owner: "octokit",
repo: "core.js",
range: ">1.2.1",
});
See CONTRIBUTING.md