Skip to content

empty file #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 89 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
692b861
Create wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
b952578
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
4fb605d
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
f2e805f
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
df598bb
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
ffb10b5
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
3e7f830
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
c6ff5df
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
cb1fc1e
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
d6300b0
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
7d25f60
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
c94b344
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
3c3a459
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
f33fa15
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
57f2b26
Update wg-windows-build-publish-.yml
zaneschepke Oct 31, 2023
99a0f52
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
002e980
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
891c42b
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
18a5702
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
3062da0
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
79dddd2
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
ea1b380
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
bb4125d
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
15c9667
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
08a329e
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
28e959f
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
0acae21
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
fbd0e2e
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
ee85f6e
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
b24f4ac
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
3a89a7d
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
1c8ddcb
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
110ba29
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
21d4b67
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
aabf6f5
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
be2ef82
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
497380d
Update wg-windows-build-publish-.yml
zaneschepke Nov 1, 2023
19c47e5
Update and rename .github/workflows/wg-windows-build-publish-.yml to …
zaneschepke Nov 3, 2023
f917e48
Update macos-build-publish.yml
zaneschepke Nov 3, 2023
11de6d1
Create macos-build-publish.yml
zaneschepke Nov 3, 2023
1cf6cc5
Update macos-build-publish.yml
zaneschepke Nov 3, 2023
1de28af
Update macos-build-publish.yml
zaneschepke Nov 3, 2023
df17cb9
Update macos-build-publish.yml
zaneschepke Nov 3, 2023
7aa74aa
Add tauri-build-publish.yml
zaneschepke Nov 10, 2023
adfa75d
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
9f5e75b
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
353ff8a
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
08a72a4
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
7b1d65b
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
7f0c692
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
226f704
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
ab02f39
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
30e8453
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
be1c869
Update tauri-build-publish.yml
zaneschepke Nov 10, 2023
f3e0ab1
Update tauri-build-publish.yml
zaneschepke Nov 12, 2023
7db1b7c
Update tauri-build-publish.yml
zaneschepke Nov 13, 2023
7d4ba2f
Update tauri-build-publish.yml
zaneschepke Nov 13, 2023
c238902
Update desktop pipeline
zaneschepke Nov 17, 2023
c6d9c24
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
7286265
Update tauri-build-publish.yml
zaneschepke Nov 17, 2023
1b09438
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
d0697bf
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
7465300
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
e968429
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
5ad57cd
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
81a32a7
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
4ed299b
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
9f4ca7d
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
1261ae1
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
c765244
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
14a3c7f
Update nymvpn-desktop.yml
zaneschepke Nov 17, 2023
8901f64
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
16f9add
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
c257832
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
7e059a3
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
f4f8d41
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
dcdc8d9
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
6f06e95
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
d517a1d
Update nymvpn-desktop.yml
zaneschepke Nov 20, 2023
0903a16
hashing and stuff
jstuczyn Nov 20, 2023
5ea8d89
use debug builds for faster CI
jstuczyn Nov 20, 2023
570111f
speed up CI: only upload 2 binaries
jstuczyn Nov 20, 2023
82eb5d0
ibid. but removed the lines because yaml
jstuczyn Nov 20, 2023
300c96e
checkout correct repo
jstuczyn Nov 20, 2023
1b892da
using correct repo in hashes
jstuczyn Nov 20, 2023
a256822
empty file
jstuczyn Nov 20, 2023
e9beeca
revert 300c96efefa94237a9fdf48ca76aa1c98fe0f88e
jstuczyn Nov 20, 2023
f5dcfcc
debug
jstuczyn Nov 20, 2023
6c61561
attempting to add bin info
jstuczyn Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/nym-hash-releases/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.tmp
hashes.json
25 changes: 25 additions & 0 deletions .github/actions/nym-hash-releases/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Nym Hash Release'
author: 'Nym Technologies SA'
description: 'Generate hashes and signatures for assets in Nym releases'
inputs:
hash-type:
description: 'Type of hash to generate (md5, sha1, sha256, sha512)'
required: false
default: 'sha256'
file-name:
description: 'File name to save as if desired'
required: false
default: 'hashes.json'
release-tag-or-name-or-id:
description: 'The tag/release to process. Uses the release id when trigger from a release.'
required: false
default: ''
outputs:
hashes:
description: 'A string containing JSON with the release asset hashes and signatures'
runs:
using: 'node16'
main: 'index.js'
branding:
icon: 'hash'
color: 'green'
282 changes: 282 additions & 0 deletions .github/actions/nym-hash-releases/create-hashes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
import hasha from "hasha";
import fetch from "node-fetch";
import { Octokit } from "@octokit/rest";
import fs from "fs";
import path from "path";
import { execSync } from "child_process";

function getBinInfo(path) {
// let's be super naive about it. add a+x bits on the file and try to run the command
try {
let mode = fs.statSync(path).mode
fs.chmodSync(path, mode | 0o111)

const raw = execSync(`${path} build-info --output=json`, { stdio: 'pipe', encoding: "utf8" });
const parsed = JSON.parse(raw)
return parsed
} catch (_) {
return undefined
}
}

async function run(assets, algorithm, filename, cache) {
if (!cache) {
console.warn("cache is set to 'false', but we we no longer support it")
}

try {
fs.mkdirSync('.tmp');
} catch(e) {
// ignore
}

const hashes = {};
let numAwaiting = 0;
for (const asset of assets) {
if (filename === "" || asset.name !== filename) { // don't hash the hash file (if the file has the same name)
numAwaiting++;

let buffer = null;
let sig = null;

// cache in `${WORKING_DIR}/.tmp/`
const cacheFilename = path.resolve(`.tmp/${asset.name}`);
if(!fs.existsSync(cacheFilename)) {
console.log(`Downloading ${asset.browser_download_url}... to ${cacheFilename}`);
buffer = Buffer.from(await fetch(asset.browser_download_url).then(res => res.arrayBuffer()));
fs.writeFileSync(cacheFilename, buffer);
} else {
console.log(`Loading from ${cacheFilename}`);
buffer = Buffer.from(fs.readFileSync(cacheFilename));

// console.log('Reading signature from content');
// if(asset.name.endsWith('.sig')) {
// sig = fs.readFileSync(cacheFilename).toString();
// }
}

const binInfo = getBinInfo(cacheFilename)

if(!hashes[asset.name]) {
hashes[asset.name] = {};
}

if(asset.name.endsWith('.sig')) {
sig = buffer.toString();
}

hashes[asset.name][algorithm] = hasha(new Uint8Array(buffer), {algorithm: algorithm});

let platform;
let kind;
if(asset.name.endsWith('.sig')) {
kind = 'signature';
}
if(asset.name.endsWith('.app.tar.gz')) {
platform = 'MacOS';
kind = 'auto-updater';
}
if(asset.name.endsWith('.app.tar.gz.sig')) {
platform = 'MacOS';
kind = 'auto-updater-signature';
}
if(asset.name.endsWith('.dmg')) {
platform = 'MacOS';
kind = 'installer';
}
if(asset.name.endsWith('.msi.zip')) {
platform = 'Windows';
kind = 'auto-updater';
}
if(asset.name.endsWith('.msi.zip.sig')) {
platform = 'Windows';
kind = 'auto-updater-signature';
}
if(asset.name.endsWith('.msi')) {
platform = 'Windows';
kind = 'installer';
}
if(asset.name.endsWith('.AppImage.tar.gz')) {
platform = 'Linux';
kind = 'auto-updater';
}
if(asset.name.endsWith('.AppImage.tar.gz.sig')) {
platform = 'Linux';
kind = 'auto-updater-signature';
}
if(asset.name.endsWith('.AppImage')) {
platform = 'Linux';
kind = 'installer';
}

hashes[asset.name].downloadUrl = asset.browser_download_url;

if(platform) {
hashes[asset.name].platform = platform;
}
if(kind) {
hashes[asset.name].kind = kind;
}
if(binInfo) {
hashes[asset.name].details = binInfo;
}

// process Tauri signature files
if(asset.name.endsWith('.sig')) {
const otherFilename = asset.name.replace('.sig', '');
if(!hashes[otherFilename]) {
hashes[otherFilename] = {};
}
hashes[otherFilename].signature = sig;
}
}
}
return hashes;
}

export async function createHashes({ assets, algorithm, filename, cache }) {
const output = await run(assets, algorithm, filename, cache);
if(filename?.length) {
fs.writeFileSync(filename, JSON.stringify(output, null, 2));
}
return output;
}

export async function createHashesFromReleaseTagOrNameOrId({ releaseTagOrNameOrId, algorithm = 'sha256', filename = 'hashes.json', cache = false, upload = true }) {
console.log("🚀🚀🚀 Getting releases");

let auth;
let authStrategy;
if(process.env.GITHUB_TOKEN) {
console.log('Using GITHUB_TOKEN for auth');
// authStrategy = createActionAuth();
// auth = await authStrategy();
}

const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
request: { fetch }
});
const owner = "nymtech";
const repo = "ci-playground";

let releases;
if(cache) {
const cacheFilename = path.resolve(`.tmp/releases.json`);
if(!fs.existsSync(cacheFilename)) {
releases = await octokit.paginate(
octokit.rest.repos.listReleases,
{
owner,
repo,
per_page: 100,
},
(response) => response.data
);
fs.writeFileSync(cacheFilename, JSON.stringify(releases, null, 2));
} else {
console.log('Loading releases from cache...');
releases = JSON.parse(fs.readFileSync(cacheFilename));
}
} else {
releases = await octokit.paginate(
octokit.rest.repos.listReleases,
{
owner,
repo,
per_page: 100,
},
(response) => response.data
)
}

// process all releases by default
let releasesToProcess = releases;

// process a single release
if(releaseTagOrNameOrId) {
releasesToProcess = releases.filter(r => {
if (r.tag_name === releaseTagOrNameOrId) {
return true;
}
if (`${r.id}` === `${releaseTagOrNameOrId}`) {
return true;
}
if (r.name === releaseTagOrNameOrId) {
return true;
}

return false;
});
}

releasesToProcess.forEach(release => {
const {tag_name, name} = release;
const tagComponents = tag_name.split('-v');
const componentName = tagComponents[0];
const componentVersion = 'v' + tagComponents[1];

if(!tagComponents[1] || !name) {
return;
}

release.componentName = componentName;
release.componentVersion = componentVersion;
})

releasesToProcess = releasesToProcess.filter(release =>
!!release.name && !!release.componentVersion
);

console.log('Releases to process:');
console.table(releasesToProcess.map(r => {
const { id, name, tag_name, componentName, componentVersion, assets } = r;
return { id, name, tag_name, componentName, componentVersion, assetCount: assets.length };
}));

for(const release of releasesToProcess) {
const {id, name, tag_name, html_url, componentName, componentVersion} = release;

const hashes = await createHashes({ assets: release.assets, algorithm, filename, cache });

const output = {
id, name, tag_name, html_url,
componentName,
componentVersion,
assets: hashes,
};

console.log(output)

if(upload) {
console.log(`🚚 Uploading ${filename} to release name="${release.name}" id=${release.id} (${release.upload_url})...`);

const exists = (await octokit.repos.listReleaseAssets({ owner, repo, release_id: release.id })).data.find(a => a.name === filename)
if (exists) {
console.log(`Deleting existing asset ${filename}...`);
await octokit.repos.deleteReleaseAsset({ owner, repo, asset_id: exists.id })
console.log('Deleted existing asset');
}

try {
const data = JSON.stringify(output, null, 2);
await octokit.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: release.id,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
},
name: filename,
data,
});
console.log('✅ Upload to release is complete.');
} catch(e) {
console.log('❌ failed to upload:', e.message, e.status, e.response.data);
console.log(e);
process.exit(-1);
}
}
}
}

15 changes: 15 additions & 0 deletions .github/actions/nym-hash-releases/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import core from "@actions/core";
import github from "@actions/github";
import { createHashesFromReleaseTagOrNameOrId } from './create-hashes.mjs';

const algorithm = core.getInput('hash-type');
const filename = core.getInput("file-name");

// use the release id from the payload if it is set
const releaseTagOrNameOrId = core.getInput("release-tag-or-name-or-id") || github.context.payload.release?.id;

try {
await createHashesFromReleaseTagOrNameOrId({ releaseTagOrNameOrId, algorithm, filename })
} catch (error) {
core.setFailed(error.message);
}
Loading