Skip to content

Commit

Permalink
Here we go?
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacksore committed Nov 22, 2023
1 parent b822385 commit c1e81f3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 233 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ jobs:
- uses: pnpm/action-setup@v2
with:
version: 8
- name: install frontend dependencies
run: pnpm install --filter ./
- name: Download bins
# TODO: convert this to github script?
run: npx tsx scripts/download-draft-bins.ts ${{ needs.create-release.outputs.release_id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download draft binaries
uses: actions/github-script@v7
with:
script: |
const { script } = await import('${{ github.workspace }}/scripts/actions/download-draft-bins.js')
const id = "${{ needs.create-release.outputs.release_id }}";
await script({ github, context }, id);
- name: Presign
run: |
ls -hal binaries
Expand All @@ -115,8 +115,7 @@ jobs:
run: |
ls -hal binaries/signed
sha1sum binaries/signed/*
- name: Create release or skip
id: create-release
- name: Sign && upload windows binaries
uses: actions/github-script@v7
with:
script: |
Expand Down
6 changes: 2 additions & 4 deletions scripts/actions/create-release.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// TODO: can we type this?

/** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
export const script = async ({ context, github }) => {
const { data: listReleases } = await github.rest.repos.listReleases({
owner: "Hacksore",
repo: "overlayed",
owner: context.repo.owner,
repo: context.repo.repo,
});

const [release] = listReleases;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
// local testing:
// op run --env-file .env -- npx tsx scripts/download-draft-bins.ts 131013514
import fs from "node:fs";
import fs from "fs";

import { Readable } from "stream";
import { finished } from "stream/promises";

const { GITHUB_TOKEN } = process.env;

if(!GITHUB_TOKEN) {
throw new Error("GITHUB_TOKEN not set")
}

async function downloadFile(url: string, filepath = "./download") {
async function downloadFile(url, filepath = "./download") {
const response = await fetch(url, {
headers: {
Accept: "application/octet-stream",
Expand All @@ -25,27 +14,19 @@ async function downloadFile(url: string, filepath = "./download") {
}

const BINARIES_DIR = "binaries";
const main = async () => {
// get first param to script
const id = process.argv[2];

if (!id) {
throw new Error("🚫 No release id provided");
}
/** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
/** @param id {String} */
export const script = async ({ context, github }, id) => {

console.log(`📦 downloading release artifacts for ${id}`);

try {
const draftData = await fetch(
`https://api.github.com/repos/Hacksore/overlayed/releases/${id}`,
{
headers: {
Accept: "application/vnd.github+json",
Authorization: `token ${GITHUB_TOKEN}`,
"X-GitHub-Api-Version": "2022-11-28",
},
},
).then((res) => res.json());
const { data: draftData } = await github.rest.repos.getRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: id,
});

console.log(draftData);

Expand All @@ -58,7 +39,6 @@ const main = async () => {
}

for (const asset of assets) {
const url = asset.browser_download_url;
const filename = asset.name;
// skip non windows bins
if (![".msi", ".exe"].some((ext) => filename.endsWith(ext))) {
Expand All @@ -76,5 +56,3 @@ const main = async () => {
console.log(err);
}
};

main();
51 changes: 0 additions & 51 deletions scripts/sandbox/test.ts

This file was deleted.

27 changes: 0 additions & 27 deletions scripts/sign/constants.ts

This file was deleted.

23 changes: 0 additions & 23 deletions scripts/sign/index.ts

This file was deleted.

39 changes: 0 additions & 39 deletions scripts/sign/mac.ts

This file was deleted.

48 changes: 0 additions & 48 deletions scripts/sign/windows.ts

This file was deleted.

0 comments on commit c1e81f3

Please sign in to comment.