2019-03-12 22:07:57 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2019 Balena Ltd.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2019-05-23 00:44:08 +00:00
|
|
|
import * as Bluebird from 'bluebird';
|
|
|
|
import * as _ from 'lodash';
|
2017-12-13 17:33:03 +00:00
|
|
|
import * as publishRelease from 'publish-release';
|
2019-03-12 22:07:57 +00:00
|
|
|
|
2019-06-02 14:23:37 +00:00
|
|
|
import { finalReleaseAssets, version } from './build-bin';
|
2017-12-13 17:33:03 +00:00
|
|
|
|
2019-06-02 14:23:37 +00:00
|
|
|
const { GITHUB_TOKEN } = process.env;
|
2019-05-23 00:44:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create or update a release in GitHub's releases page, uploading the
|
|
|
|
* installer files (standalone zip + native oclif installers).
|
|
|
|
*/
|
|
|
|
export async function createGitHubRelease() {
|
|
|
|
console.log(`Publishing release ${version} to GitHub`);
|
|
|
|
const ghRelease = await Bluebird.fromCallback(
|
|
|
|
publishRelease.bind(null, {
|
2019-03-12 22:07:57 +00:00
|
|
|
token: GITHUB_TOKEN || '',
|
2018-10-19 14:38:50 +00:00
|
|
|
owner: 'balena-io',
|
|
|
|
repo: 'balena-cli',
|
2018-01-09 15:05:24 +00:00
|
|
|
tag: version,
|
2018-10-19 14:38:50 +00:00
|
|
|
name: `balena-CLI ${version}`,
|
2018-01-09 15:05:24 +00:00
|
|
|
reuseRelease: true,
|
2019-05-23 00:44:08 +00:00
|
|
|
assets: finalReleaseAssets[process.platform],
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
console.log(`Release ${version} successful: ${ghRelease.html_url}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Top-level function to create a CLI release in GitHub's releases page:
|
|
|
|
* call zipStandaloneInstaller(), rename the files as we'd like them to
|
|
|
|
* display on the releases page, and call createGitHubRelease() to upload
|
|
|
|
* the files.
|
|
|
|
*/
|
|
|
|
export async function release() {
|
|
|
|
try {
|
|
|
|
await createGitHubRelease();
|
|
|
|
} catch (err) {
|
2018-01-09 15:05:24 +00:00
|
|
|
console.error('Release failed');
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
2019-05-23 00:44:08 +00:00
|
|
|
}
|
|
|
|
}
|