build: add GitHub Actions publishing pipeline for macOS (#42236)

* build: add publishing workflow for GHActions

* build: add test repo/bucket for uploads

* build: clean up conditionals, add macos-14-large, review comments

* build: remove host_cpu var from GCLIENT_EXTRA_ARGS
This commit is contained in:
Keeley Hammond 2024-05-31 10:58:39 -07:00 committed by GitHub
parent 4436ce53bc
commit 361b37592a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 341 additions and 83 deletions

View file

@ -8,13 +8,14 @@ else
BUILD_TYPE="mas"
fi
rm -rf generated_artifacts_${BUILD_TYPE}
mkdir generated_artifacts_${BUILD_TYPE}
echo Creating generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}...
rm -rf generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}
mkdir generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}
mv_if_exist() {
if [ -f "$1" ] || [ -d "$1" ]; then
echo Storing $1
mv $1 generated_artifacts_${BUILD_TYPE}
mv $1 generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}
else
echo Skipping $1 - It is not present on disk
fi
@ -22,7 +23,7 @@ mv_if_exist() {
cp_if_exist() {
if [ -f "$1" ] || [ -d "$1" ]; then
echo Storing $1
cp $1 generated_artifacts_${BUILD_TYPE}
cp $1 generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}
else
echo Skipping $1 - It is not present on disk
fi

View file

@ -1,12 +1,12 @@
#!/bin/sh
#!/bin/bash
set -eo pipefail
mv_if_exist() {
if [ -f "generated_artifacts_${BUILD_TYPE}/$1" ] || [ -d "generated_artifacts_${BUILD_TYPE}/$1" ]; then
if [ -f "generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1" ] || [ -d "generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1" ]; then
echo Restoring $1 to $2
mkdir -p $2
mv generated_artifacts_${BUILD_TYPE}/$1 $2
mv generated_artifacts_${BUILD_TYPE_${TARGET_ARCH}}/$1 $2
else
echo Skipping $1 - It is not present on disk
fi

View file

@ -2,6 +2,9 @@
const { BlobServiceClient } = require('@azure/storage-blob');
const path = require('node:path');
// TODO(vertedinde): This variable is a test variable in GHA, sending test
// artifacts to a test account. Change to the real electron artifacts
// storage account when ready.
const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.ELECTRON_ARTIFACTS_BLOB_STORAGE);
const args = require('minimist')(process.argv.slice(2));

View file

@ -36,10 +36,6 @@ const ghActionsPublishWorkflows = [
'macos-publish'
];
const ghActionsPublishIndividualArches = {
'macos-publish': ['osx-x64', 'mas-x64', 'osx-arm64', 'mas-arm64']
};
let jobRequestedCount = 0;
async function makeRequest ({ auth, username, password, url, headers, body, method }) {
@ -82,11 +78,6 @@ async function githubActionsCall (targetBranch, workflowName, options) {
buildRequest.parameters['upload-to-storage'] = '1';
}
buildRequest.parameters[`run-${workflowName}`] = true;
if (options.arch) {
const validArches = ghActionsPublishIndividualArches[workflowName];
assert(validArches.includes(options.arch), `Unknown GitHub Actions architecture "${options.arch}". Valid values are ${JSON.stringify(validArches)}`);
buildRequest.parameters['macos-publish-arch-limit'] = options.arch;
}
jobRequestedCount++;
try {
@ -430,8 +421,7 @@ function runRelease (targetBranch, options) {
} else {
buildCircleCI(targetBranch, options);
buildAppVeyor(targetBranch, options);
// TODO(vertedinde): Enable GH Actions in defaults when ready
// buildGHActions(targetBranch, options);
buildGHActions(targetBranch, options);
}
console.log(`${jobRequestedCount} jobs were requested.`);
}

View file

@ -11,11 +11,17 @@ if (process.argv.length < 3) {
}
const version = process.argv[2];
const targetRepo = findRepo();
function findRepo () {
if (process.env.IS_GHA_RELEASE) return 'test-releases';
else return version.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
}
async function findRelease () {
const releases = await octokit.repos.listReleases({
owner: 'electron',
repo: version.indexOf('nightly') > 0 ? 'nightlies' : 'electron'
repo: targetRepo
});
const targetRelease = releases.data.find(release => release.tag_name === version);

View file

@ -14,7 +14,12 @@ const readline = require('node:readline');
const releaseNotesGenerator = require('./notes/index.js');
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils.js');
const bumpType = args._[0];
const targetRepo = bumpType === 'nightly' ? 'nightlies' : 'electron';
const targetRepo = getRepo();
function getRepo () {
if (process.env.IS_GHA_RELEASE) return 'test-releases';
return bumpType === 'nightly' ? 'nightlies' : 'electron';
}
const octokit = new Octokit({
auth: process.env.ELECTRON_GITHUB_TOKEN

View file

@ -45,6 +45,12 @@ let npmTag = '';
const currentElectronVersion = getElectronVersion();
const isNightlyElectronVersion = currentElectronVersion.includes('nightly');
const targetRepo = getRepo();
function getRepo () {
if (process.env.IS_GHA_RELEASE) return 'test-releases';
return isNightlyElectronVersion ? 'nightlies' : 'electron';
}
new Promise((resolve, reject) => {
temp.mkdir('electron-npm', (err, dirPath) => {
@ -78,7 +84,7 @@ new Promise((resolve, reject) => {
return octokit.repos.listReleases({
owner: 'electron',
repo: isNightlyElectronVersion ? 'nightlies' : 'electron'
repo: targetRepo
});
})
.then((releases) => {
@ -98,7 +104,7 @@ new Promise((resolve, reject) => {
}
const typingsContent = await getAssetContents(
isNightlyElectronVersion ? 'nightlies' : 'electron',
targetRepo,
tsdAsset.id
);
@ -113,7 +119,7 @@ new Promise((resolve, reject) => {
}
const checksumsContent = await getAssetContents(
isNightlyElectronVersion ? 'nightlies' : 'electron',
targetRepo,
checksumsAsset.id
);

View file

@ -32,7 +32,12 @@ const octokit = new Octokit({
auth: process.env.ELECTRON_GITHUB_TOKEN
});
const targetRepo = pkgVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
function getRepo () {
if (process.env.IS_GHA_RELEASE) return 'test-releases';
return pkgVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
}
const targetRepo = getRepo();
let failureCount = 0;
async function getDraftRelease (version, skipValidation) {

View file

@ -43,7 +43,12 @@ const getHeaders = (filePath: string, fileName: string) => {
};
};
const targetRepo = releaseVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
function getRepo () {
if (process.env.IS_GHA_RELEASE) return 'test-releases';
return releaseVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron';
}
const targetRepo = getRepo();
const uploadUrl = `https://uploads.github.com/repos/electron/${targetRepo}/releases/${releaseId}/assets{?name,label}`;
let retry = 0;