mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-31 05:29:58 +01:00
Switch fetch-package to use Github instead of Buildkite (#412)
* Switch fetch-package to use Github instead of Buildkite * Tweak build to version match better * Fix version match fetching * Remove check for `BUILDKITE_API_KEY` as it is no longer required * Fix develop fetching
This commit is contained in:
parent
497c4695fd
commit
b14a1eb3a8
7
.github/workflows/build.yaml
vendored
7
.github/workflows/build.yaml
vendored
@ -20,8 +20,13 @@ jobs:
|
|||||||
- name: Install Deps
|
- name: Install Deps
|
||||||
run: "yarn install --pure-lockfile"
|
run: "yarn install --pure-lockfile"
|
||||||
|
|
||||||
|
- name: Fetch Element Web (develop)
|
||||||
|
if: github.event.pull_request.base.ref == 'develop'
|
||||||
|
run: yarn run fetch --noverify develop -d element.io/nightly
|
||||||
|
|
||||||
- name: Fetch Element Web
|
- name: Fetch Element Web
|
||||||
run: yarn run fetch --noverify --cfgdir element.io/nightly
|
if: github.event.pull_request.base.ref != 'develop'
|
||||||
|
run: yarn run fetch --noverify --cfgdir element.io/release
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -14,70 +14,9 @@ const { setPackageVersion } = require('./set-version.js');
|
|||||||
|
|
||||||
const PUB_KEY_URL = "https://packages.riot.im/element-release-key.asc";
|
const PUB_KEY_URL = "https://packages.riot.im/element-release-key.asc";
|
||||||
const PACKAGE_URL_PREFIX = "https://github.com/vector-im/element-web/releases/download/";
|
const PACKAGE_URL_PREFIX = "https://github.com/vector-im/element-web/releases/download/";
|
||||||
|
const DEVELOP_TGZ_URL = "https://vector-im.github.io/element-web/develop.tar.gz";
|
||||||
const ASAR_PATH = 'webapp.asar';
|
const ASAR_PATH = 'webapp.asar';
|
||||||
|
|
||||||
async function getLatestDevelopUrl(bkToken) {
|
|
||||||
const buildsResult = await needle('get',
|
|
||||||
"https://api.buildkite.com/v2/organizations/matrix-dot-org/pipelines/element-web/builds",
|
|
||||||
{
|
|
||||||
branch: 'develop',
|
|
||||||
state: 'passed',
|
|
||||||
per_page: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
authorization: "Bearer " + bkToken,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const latestBuild = buildsResult.body[0];
|
|
||||||
console.log("Latest build is " + latestBuild.number);
|
|
||||||
let artifactUrl;
|
|
||||||
for (const job of latestBuild.jobs) {
|
|
||||||
// Strip any colon-form emoji from the build name
|
|
||||||
if (job.name && job.name.replace(/:\w*:\s*/, '') === 'Package') {
|
|
||||||
artifactUrl = job.artifacts_url;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (artifactUrl === undefined) {
|
|
||||||
throw new Error("Couldn't find artifact URL - has the name of the package job changed?");
|
|
||||||
}
|
|
||||||
|
|
||||||
const artifactsResult = await needle('get', artifactUrl, {},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
authorization: "Bearer " + bkToken,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
let dlUrl;
|
|
||||||
let dlFilename;
|
|
||||||
for (const artifact of artifactsResult.body) {
|
|
||||||
if (artifact.filename && /^element-.*\.tar.gz$/.test(artifact.filename)) {
|
|
||||||
dlUrl = artifact.download_url;
|
|
||||||
dlFilename = artifact.filename;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dlUrl === undefined) {
|
|
||||||
throw new Error("Couldn't find artifact download URL - has the artifact filename changed?");
|
|
||||||
}
|
|
||||||
console.log("Fetching artifact URL...");
|
|
||||||
const dlResult = await needle('get', dlUrl, {},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
authorization: "Bearer " + bkToken,
|
|
||||||
},
|
|
||||||
// This URL will give us a Location header, but will also give us
|
|
||||||
// a JSON object with the direct URL. We'll take the URL and pass it
|
|
||||||
// back, then we can easily support specifying a URL directly.
|
|
||||||
follow_max: 0,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return [dlFilename, dlResult.body.url];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function downloadToFile(url, filename) {
|
async function downloadToFile(url, filename) {
|
||||||
console.log("Downloading " + url + "...");
|
console.log("Downloading " + url + "...");
|
||||||
|
|
||||||
@ -148,24 +87,17 @@ async function main() {
|
|||||||
|
|
||||||
if (targetVersion === undefined) {
|
if (targetVersion === undefined) {
|
||||||
targetVersion = 'v' + riotDesktopPackageJson.version;
|
targetVersion = 'v' + riotDesktopPackageJson.version;
|
||||||
filename = 'element-' + targetVersion + '.tar.gz';
|
} else if (targetVersion !== 'develop') {
|
||||||
url = PACKAGE_URL_PREFIX + targetVersion + '/' + filename;
|
setVersion = true; // version was specified
|
||||||
} else if (targetVersion === 'develop') {
|
}
|
||||||
const buildKiteApiKey = process.env.BUILDKITE_API_KEY;
|
|
||||||
if (buildKiteApiKey === undefined) {
|
if (targetVersion === 'develop') {
|
||||||
console.log("Set BUILDKITE_API_KEY to fetch latest develop version");
|
filename = 'develop.tar.gz';
|
||||||
console.log(
|
url = DEVELOP_TGZ_URL;
|
||||||
"Sorry - Buildkite's API requires authentication to access builds, " +
|
|
||||||
"even if those builds are accessible on the web with no auth.",
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
[filename, url] = await getLatestDevelopUrl(buildKiteApiKey);
|
|
||||||
verify = false; // develop builds aren't signed
|
verify = false; // develop builds aren't signed
|
||||||
} else {
|
} else {
|
||||||
filename = 'element-' + targetVersion + '.tar.gz';
|
filename = 'element-' + targetVersion + '.tar.gz';
|
||||||
url = PACKAGE_URL_PREFIX + targetVersion + '/' + filename;
|
url = PACKAGE_URL_PREFIX + targetVersion + '/' + filename;
|
||||||
setVersion = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const haveGpg = await new Promise((resolve) => {
|
const haveGpg = await new Promise((resolve) => {
|
||||||
@ -207,7 +139,7 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let haveDeploy = false;
|
let haveDeploy = false;
|
||||||
const expectedDeployDir = path.join(deployDir, path.basename(filename).replace(/\.tar\.gz/, ''));
|
let expectedDeployDir = path.join(deployDir, path.basename(filename).replace(/\.tar\.gz/, ''));
|
||||||
try {
|
try {
|
||||||
await fs.opendir(expectedDeployDir);
|
await fs.opendir(expectedDeployDir);
|
||||||
console.log(expectedDeployDir + "already exists");
|
console.log(expectedDeployDir + "already exists");
|
||||||
@ -256,6 +188,12 @@ async function main() {
|
|||||||
await tar.x({
|
await tar.x({
|
||||||
file: outPath,
|
file: outPath,
|
||||||
cwd: deployDir,
|
cwd: deployDir,
|
||||||
|
onentry: entry => {
|
||||||
|
// Find the appropriate extraction path, only needed for `develop` where the dir name is unknown
|
||||||
|
if (entry.type === "Directory" && !path.join(deployDir, entry.path).startsWith(expectedDeployDir)) {
|
||||||
|
expectedDeployDir = path.join(deployDir, entry.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,4 +225,9 @@ async function main() {
|
|||||||
console.log("Done!");
|
console.log("Done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
main().then((ret) => process.exit(ret)).catch(e => process.exit(1));
|
main().then((ret) => {
|
||||||
|
process.exit(ret);
|
||||||
|
}).catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user