Skip to content

Releasing Binaries

Caleb Hearon edited this page Nov 25, 2019 · 9 revisions

To build a new release, first create a new GitHub release by creating a tag (e.g. v2.0.0-alpha.1) and then use Draft a new release and publish a release of the same name. The commit that the tag points to doesn't matter since releases are only for hosting binaries.

Next, CI must have four environment variables set:

Variable Description
PREBUILD_AUTH Set this to a Personal Access Token that has the repo permission and everything underneath. ci/release.js uses this to have permission to upload tarballs to GitHub.
PREBUILD_CANVAS_VERSION This is the version of canvas that will be downloaded and built.
PREBUILD_VERSION This is the version that the binaries will be uploaded to on GitHub. Usually this is the same as PREBUILD_CANVAS_VERSION, but having two separate variables allows for extra / test canvas-prebuilt releases.
PREBUILD_NODE_VERSIONS Space-separated list of nodejs versions to use (e.g. "12.4.0 11.15.0"). They do need to be in quotes in AppVeyor, Travis as of #80. This is specified in an environment variable so we can rebuild old commits with new node versions. Changes to canvas-prebuilt's build system might produce different object code, and changing binaries people are already using can cause problems. See below for a helper script to generate this list.

With these variables set, re-run the latest commit on master and the binaries will be automatically uploaded to GitHub. When the release is done, make sure to delete the environment variables. Otherwise, each time master is pushed to or tagged, CI will keep updating releases. There isn't a way to turn off auto-building on Travis/AppVeyor without having unwanted side-effects.

Listing the latest version of each major Node.js release

You can use the following script to generate the value for PREBUILD_NODE_VERSIONS (copying the desired version range, e.g. stopping at v6.x.x and/or omitting odd numbers).

const https = require("https");

https.get("https://nodejs.org/dist/index.json", res => {
    if (res.statusCode !== 200) throw new Error(`Error ${res.statusCode}`);

    const buffs = [];
    res.on("data", d => buffs.push(d));
    res.on("end", () => {
        const parsed = JSON.parse(Buffer.concat(buffs));

        // Releases are in descending order.
        const latest = new Map();
        for (const release of parsed) {
            if (!latest.has(release.modules)) {
                latest.set(release.modules, release.version.slice(1));
            }
        }
        console.log(`"${[...latest.values()].join(' ')}"`);
    });
});
> node .\latest-versions.js
"13.2.0 12.13.1 11.15.0 10.17.0 9.11.2 8.16.2 7.10.1 6.17.1 5.12.0 4.9.1 0.12.18 0.11.10 0.11.7 0.10.48 0.10.3 0.9.8 0.9.0 0.1.104"
Clone this wiki locally