Skip to content

Commit cbcfd15

Browse files
committed
fix(ci): get binaries uploading
1 parent 3bcc74f commit cbcfd15

File tree

14 files changed

+277
-283
lines changed

14 files changed

+277
-283
lines changed

.github/workflows/release.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ jobs:
5555
# git config --global user.name "github-actions[bot]"
5656
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
5757

58-
# # Install Deno
59-
# curl -fsSL https://deno.land/x/install/install.sh | sh
60-
# export PATH=$HOME/.deno/bin:$PATH
61-
6258
# # Authenticate with NPM
6359
# cat << EOF > ~/.npmrc
6460
# //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
6561
# EOF
6662

63+
# # Install dependencies
6764
# pnpm install
6865

66+
# # Install tsx globally
67+
# npm install -g tsx
68+
6969
# if [ "${{ inputs.latest }}" = "true" ]; then
7070
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --setupCi
7171
# else
@@ -224,6 +224,12 @@ jobs:
224224
# with:
225225
# lfs: 'true'
226226

227+
# - uses: actions/setup-node@v4
228+
# with:
229+
# node-version: 20
230+
231+
# - run: corepack enable
232+
227233
# - uses: ./.github/actions/docker-setup
228234
# with:
229235
# docker_username: ${{ secrets.DOCKER_CI_USERNAME }}
@@ -235,12 +241,14 @@ jobs:
235241
# R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
236242
# R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
237243
# run: |
238-
# # Install Deno
239-
# curl -fsSL https://deno.land/x/install/install.sh | sh
240-
# export PATH=$HOME/.deno/bin:$PATH
244+
# # Install dependencies
245+
# pnpm install
246+
247+
# # Install tsx globally
248+
# npm install -g tsx
241249

242250
# if [ "${{ inputs.latest }}" = "true" ]; then
243251
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --completeCi
244252
# else
245253
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --completeCi
246-
# fi
254+
# fi

pnpm-lock.yaml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ packages:
22
- docker/template
33
- frontend
44
- scripts/tests
5+
- scripts/release
56
- sdks/typescript/api-full
67
- sdks/typescript/api-runtime
78
- sdks/typescript/runner

scripts/release/artifacts.ts

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,93 @@
11
import type { ReleaseOpts } from "./main.ts";
2-
import { assertExists } from "@std/assert/exists";
3-
import $, { CommandBuilder } from "dax";
4-
import { assert } from "@std/assert/assert";
5-
import { resolve } from "@std/path";
2+
import { $ } from "execa";
3+
import * as path from "node:path";
4+
import * as fs from "node:fs/promises";
5+
6+
function assert(condition: any, message?: string): asserts condition {
7+
if (!condition) {
8+
throw new Error(message || "Assertion failed");
9+
}
10+
}
611

712
export async function updateArtifacts(opts: ReleaseOpts) {
813
// Get credentials and set them in the environment
9-
const awsAccessKeyId =
10-
Deno.env.get("R2_RELEASES_ACCESS_KEY_ID") ??
11-
(await $`op read "op://Engineering/rivet-releases R2 Upload/username"`.text());
12-
const awsSecretAccessKey =
13-
Deno.env.get("R2_RELEASES_SECRET_ACCESS_KEY") ??
14-
(await $`op read "op://Engineering/rivet-releases R2 Upload/password"`.text());
14+
let awsAccessKeyId = process.env.R2_RELEASES_ACCESS_KEY_ID;
15+
if (!awsAccessKeyId) {
16+
const result = await $`op read "op://Engineering/rivet-releases R2 Upload/username"`;
17+
awsAccessKeyId = result.stdout.trim();
18+
}
19+
let awsSecretAccessKey = process.env.R2_RELEASES_SECRET_ACCESS_KEY;
20+
if (!awsSecretAccessKey) {
21+
const result = await $`op read "op://Engineering/rivet-releases R2 Upload/password"`;
22+
awsSecretAccessKey = result.stdout.trim();
23+
}
1524

1625
const endpointUrl = "https://2a94c6a0ced8d35ea63cddc86c2681e7.r2.cloudflarestorage.com";
1726

18-
// Create AWS CLI command builder with credentials
19-
const awsCommand = new CommandBuilder().env({
27+
// Create AWS environment for commands
28+
const awsEnv = {
2029
AWS_ACCESS_KEY_ID: awsAccessKeyId,
2130
AWS_SECRET_ACCESS_KEY: awsSecretAccessKey,
2231
AWS_DEFAULT_REGION: "auto",
23-
});
32+
};
2433

2534
// List all files under rivet/{commit}/
2635
const commitPrefix = `rivet/${opts.commit}/`;
27-
$.logStep("Listing Original Files", commitPrefix);
28-
const commitFiles = await awsCommand
29-
.command(
30-
`aws s3api list-objects --bucket rivet-releases --prefix ${commitPrefix} --endpoint-url ${endpointUrl}`,
31-
)
32-
.json();
36+
console.log(`==> Listing Original Files: ${commitPrefix}`);
37+
const listResult = await $({ env: awsEnv, shell: true })`aws s3api list-objects --bucket rivet-releases --prefix ${commitPrefix} --endpoint-url ${endpointUrl}`;
38+
const commitFiles = JSON.parse(listResult.stdout);
3339
assert(
3440
Array.isArray(commitFiles?.Contents) && commitFiles.Contents.length > 0,
3541
`No files found under rivet/${opts.commit}/`,
3642
);
3743

3844
// Copy files to version directory
3945
const versionTarget = `rivet/${opts.version}/`;
40-
await copyFiles(awsCommand, commitPrefix, versionTarget, endpointUrl);
41-
await generateInstallScripts(awsCommand, opts, opts.version, endpointUrl);
46+
await copyFiles(awsEnv, commitPrefix, versionTarget, endpointUrl);
47+
await generateInstallScripts(awsEnv, opts, opts.version, endpointUrl);
4248

4349
// If this is the latest version, copy to latest directory
4450
if (opts.latest) {
45-
await copyFiles(awsCommand, commitPrefix, "rivet/latest/", endpointUrl);
46-
await generateInstallScripts(awsCommand, opts, "latest", endpointUrl);
51+
await copyFiles(awsEnv, commitPrefix, "rivet/latest/", endpointUrl);
52+
await generateInstallScripts(awsEnv, opts, "latest", endpointUrl);
4753
}
4854
}
4955

5056
async function copyFiles(
51-
awsCommand: CommandBuilder,
57+
awsEnv: Record<string, string>,
5258
sourcePrefix: string,
5359
targetPrefix: string,
5460
endpointUrl: string,
5561
) {
56-
$.logStep("Copying Files", targetPrefix);
57-
await $.logGroup(async () => {
58-
// Delete existing files in target directory using --recursive
59-
$.logStep("Deleting existing files in", targetPrefix);
60-
await awsCommand
61-
.command(`aws s3 rm s3://rivet-releases/${targetPrefix} --recursive --endpoint-url ${endpointUrl}`)
62-
.spawn();
62+
console.log(`==> Copying Files: ${targetPrefix}`);
63+
// Delete existing files in target directory using --recursive
64+
console.log(`Deleting existing files in ${targetPrefix}`);
65+
await $({ env: awsEnv, shell: true })`aws s3 rm s3://rivet-releases/${targetPrefix} --recursive --endpoint-url ${endpointUrl}`;
6366

64-
// Copy new files using --recursive
65-
$.logStep("Copying files from", sourcePrefix, "to", targetPrefix);
66-
await awsCommand
67-
.command(
68-
`aws s3 cp s3://rivet-releases/${sourcePrefix} s3://rivet-releases/${targetPrefix} --recursive --copy-props none --endpoint-url ${endpointUrl}`,
69-
)
70-
.spawn();
71-
});
67+
// Copy new files using --recursive
68+
console.log(`Copying files from ${sourcePrefix} to ${targetPrefix}`);
69+
await $({ env: awsEnv, shell: true })`aws s3 cp s3://rivet-releases/${sourcePrefix} s3://rivet-releases/${targetPrefix} --recursive --copy-props none --endpoint-url ${endpointUrl}`;
7270
}
7371

7472
async function generateInstallScripts(
75-
awsCommand: CommandBuilder,
73+
awsEnv: Record<string, string>,
7674
opts: ReleaseOpts,
7775
version: string,
7876
endpointUrl: string,
7977
) {
8078
const installScriptPaths = [
81-
resolve(opts.root, "scripts/release/static/install.sh"),
82-
resolve(opts.root, "scripts/release/static/install.ps1"),
79+
path.resolve(opts.root, "scripts/release/static/install.sh"),
80+
path.resolve(opts.root, "scripts/release/static/install.ps1"),
8381
];
8482

8583
for (const scriptPath of installScriptPaths) {
86-
let scriptContent = await Deno.readTextFile(scriptPath);
84+
let scriptContent = await fs.readFile(scriptPath, 'utf-8');
8785
scriptContent = scriptContent.replace(/__VERSION__/g, version);
8886

8987
const uploadKey = `rivet/${version}/${scriptPath.split("/").pop() ?? ""}`;
9088

9189
// Upload the install script to S3
92-
$.logStep("Uploading Install Script", uploadKey);
93-
await awsCommand
94-
.command(`aws s3 cp - s3://rivet-releases/${uploadKey} --endpoint-url ${endpointUrl}`)
95-
.stdinText(scriptContent)
96-
.spawn();
90+
console.log(`==> Uploading Install Script: ${uploadKey}`);
91+
await $({ env: awsEnv, input: scriptContent, shell: true })`aws s3 cp - s3://rivet-releases/${uploadKey} --endpoint-url ${endpointUrl}`;
9792
}
9893
}

scripts/release/docker.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import $ from "dax";
1+
import { $ } from "execa";
22

33
const REPOS = [
44
{ name: "rivetgg/rivet-server", prefix: "slim", main: true },
@@ -11,9 +11,10 @@ const REPOS = [
1111
export async function tagDocker(opts: { version: string; commit: string; latest: boolean }) {
1212
for (const { name, prefix, main } of REPOS) {
1313
// Check image exists
14-
$.logStep("Pulling", `${name}:${prefix}-${opts.commit}`);
15-
const imageExists = await $`docker pull --platform amd64 ${name}:${prefix}-${opts.commit}`.quiet().noThrow();
16-
if (imageExists.code !== 0) {
14+
console.log(`==> Pulling: ${name}:${prefix}-${opts.commit}`);
15+
try {
16+
await $({ stdout: 'ignore', stderr: 'ignore' })`docker pull --platform amd64 ${name}:${prefix}-${opts.commit}`;
17+
} catch (error) {
1718
throw new Error(`Image ${name}:${prefix}-${opts.commit} does not exist on Docker Hub.`);
1819
}
1920

@@ -34,7 +35,7 @@ export async function tagDocker(opts: { version: string; commit: string; latest:
3435
}
3536

3637
async function tag(image: string, from: string, to: string) {
37-
$.logStep("Tagging", `${image}:${from} -> ${image}:${to}`);
38+
console.log(`==> Tagging: ${image}:${from} -> ${image}:${to}`);
3839
await $`docker tag ${image}:${from} ${image}:${to}`;
3940
await $`docker push ${image}:${to}`;
4041
}

scripts/release/git.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type { ReleaseOpts } from "./main.ts";
2-
import $ from "dax";
2+
import { $ } from "execa";
33

44
export async function validateGit(_opts: ReleaseOpts) {
55
// Validate there's no uncommitted changes
6-
const status = await $`git status --porcelain`.text();
6+
const result = await $`git status --porcelain`;
7+
const status = result.stdout;
78
if (status.trim().length > 0) {
89
throw new Error(
910
"There are uncommitted changes. Please commit or stash them.",

0 commit comments

Comments
 (0)