CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
// Modules we use:
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var spawnSync = require('child_process').spawnSync;
|
|
|
|
|
|
|
|
// Command names per-platform:
|
|
|
|
var commandNames = {
|
|
|
|
linux: 'packager-linux',
|
|
|
|
darwin: 'packager-osx',
|
|
|
|
win32: 'packager-win.exe',
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get the current package version:
|
|
|
|
var package = require(path.resolve(__dirname, 'package.json'));
|
|
|
|
console.log('Preparing Shaka Packager v' + package.version);
|
|
|
|
|
2021-06-17 20:36:56 +00:00
|
|
|
// Calculate the repo name. In GitHub Actions context, this will pull binaries
|
|
|
|
// correctly from a fork. When run by hand, it will default to the official
|
|
|
|
// repo.
|
|
|
|
var repo = process.env.GITHUB_REPOSITORY || 'google/shaka-packager';
|
|
|
|
|
CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
// For fetching binaries from GitHub:
|
2021-06-17 20:36:56 +00:00
|
|
|
var urlBase = 'https://github.com/' + repo + '/releases/download/v' +
|
CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
package.version + '/';
|
|
|
|
|
|
|
|
// For spawning curl subprocesses:
|
|
|
|
var options = {
|
|
|
|
detached: false, // Do not let the child process continue without us
|
|
|
|
stdio: 'inherit', // Pass stdin/stdout/stderr straight through
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create the bin folder if needed:
|
|
|
|
var binFolderPath = path.resolve(__dirname, 'bin');
|
|
|
|
if (!fs.existsSync(binFolderPath)) {
|
|
|
|
fs.mkdirSync(binFolderPath, 0755);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wipe the bin folder's contents if needed:
|
|
|
|
fs.readdirSync(binFolderPath).forEach(function(childName) {
|
|
|
|
var childPath = path.resolve(binFolderPath, childName);
|
|
|
|
fs.unlinkSync(childPath);
|
|
|
|
});
|
|
|
|
|
|
|
|
for (var platform in commandNames) {
|
|
|
|
// Find the destination for this binary:
|
|
|
|
var command = commandNames[platform];
|
|
|
|
var binaryPath = path.resolve(binFolderPath, command);
|
|
|
|
|
|
|
|
download(urlBase + command, binaryPath);
|
|
|
|
fs.chmodSync(binaryPath, 0755);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fetch LICENSE and README files from the same tag, and include them in the
|
|
|
|
// package.
|
2021-06-17 20:36:56 +00:00
|
|
|
var licenseUrl = 'https://raw.githubusercontent.com/' + repo + '/' +
|
CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
'v' + package.version + '/LICENSE';
|
|
|
|
download(licenseUrl, 'LICENSE');
|
|
|
|
|
2021-06-17 20:36:56 +00:00
|
|
|
var readmeUrl = 'https://raw.githubusercontent.com/' + repo + '/' +
|
CI overhaul based on GitHub Actions
This replaces Travis (for Linux & Mac) and Appveyor (for Windows) with
GitHub Actions. In addition to using GitHub Actions to test PRs, this
also expands the automation of releases so that the only manual steps
are:
1. Create a new CHANGELOG.md entry
2. Create a release tag
Workflows have been create for building and testing PRs and releases,
for publishing releases to GitHub, NPM, and Docker Hub, and for
updating documentation on GitHub Pages.
When a new PR is created, GitHub Actions will:
- Build and test on all combinations of OS, release type, and library
type
Appveyor's workflow took ~2 hours, whereas the new GitHub Actions
workflow takes ~30 minutes.
When a new release tag is created, GitHub Actions will:
- Create a draft release on GitHub
- Extract release notes from CHANGELOG.md & attach them to the
draft release
- Build and test on all combinations of OS, release type, and library
type, aborting if any build or test fails
- Attach release artifacts to the draft release, aborting if any
one artifact can't be prepared
- Fully publish the draft release on GitHub
- Publish the same release to NPM (triggered by GitHub release)
- Publish the same release to Docker Hub (triggered by GitHub release)
- Update the docs on GitHub pages
Closes #336 (GitHub Actions workflow to replace Travis and Appveyor)
b/190743862 (internal; tracking replacement of Travis)
Change-Id: Ic53eef60a8587c5d1487769a0cefaa16eb9b46e7
2021-06-10 21:40:14 +00:00
|
|
|
'v' + package.version + '/README.md';
|
|
|
|
download(readmeUrl, 'README.md');
|
|
|
|
|
|
|
|
console.log('Done!');
|
|
|
|
|
|
|
|
|
|
|
|
// Generic download helper
|
|
|
|
function download(url, outputPath) {
|
|
|
|
// Curl args:
|
|
|
|
var args = [
|
|
|
|
'-L', // follow redirects
|
|
|
|
'-f', // fail if the request fails
|
|
|
|
// output destination:
|
|
|
|
'-o',
|
|
|
|
outputPath,
|
|
|
|
'--show-error', // show errors
|
|
|
|
'--silent', // but no progress bar
|
|
|
|
url,
|
|
|
|
];
|
|
|
|
|
|
|
|
// Now fetch the binary and fail the script if that fails:
|
|
|
|
console.log('Downloading', url, 'to', outputPath);
|
|
|
|
var returnValue = spawnSync('curl', args, options);
|
|
|
|
if (returnValue.status != 0) {
|
|
|
|
process.exit(returnValue.status);
|
|
|
|
}
|
|
|
|
}
|