Skip to content

Commit 2b68468

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

File tree

14 files changed

+347
-353
lines changed

14 files changed

+347
-353
lines changed

.github/workflows/release.yaml

Lines changed: 86 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,57 @@ env:
2424
RUSTFLAGS: "--cfg tokio_unstable"
2525

2626
jobs:
27-
# setup:
28-
# name: "Setup"
29-
# runs-on: ubuntu-24.04
30-
# permissions:
31-
# # Allow pushing to GitHub
32-
# contents: write
33-
# # Allows JSR to authenticate with GitHub
34-
# id-token: write
35-
# steps:
36-
# - name: Checkout rivet
37-
# uses: actions/checkout@v4
38-
# with:
39-
# lfs: 'true'
40-
# path: './rivet'
41-
42-
# - uses: actions/setup-node@v4
43-
# with:
44-
# node-version: 20
45-
46-
# - run: corepack enable
47-
48-
# - name: Setup
49-
# env:
50-
# # Required to authenticate with Git
51-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
# working-directory: './rivet'
53-
# run: |
54-
# # Configure Git
55-
# git config --global user.name "github-actions[bot]"
56-
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
57-
58-
# # Install Deno
59-
# curl -fsSL https://deno.land/x/install/install.sh | sh
60-
# export PATH=$HOME/.deno/bin:$PATH
61-
62-
# # Authenticate with NPM
63-
# cat << EOF > ~/.npmrc
64-
# //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
65-
# EOF
66-
67-
# pnpm install
68-
69-
# if [ "${{ inputs.latest }}" = "true" ]; then
70-
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --setupCi
71-
# else
72-
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --setupCi
73-
# fi
27+
setup:
28+
name: "Setup"
29+
runs-on: ubuntu-24.04
30+
permissions:
31+
# Allow pushing to GitHub
32+
contents: write
33+
# Allows JSR to authenticate with GitHub
34+
id-token: write
35+
steps:
36+
- name: Checkout rivet
37+
uses: actions/checkout@v4
38+
with:
39+
lfs: 'true'
40+
path: './rivet'
41+
42+
- uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
46+
- run: corepack enable
47+
48+
- name: Setup
49+
env:
50+
# Required to authenticate with Git
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
working-directory: './rivet'
53+
run: |
54+
# Configure Git
55+
git config --global user.name "github-actions[bot]"
56+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
57+
58+
# Authenticate with NPM
59+
cat << EOF > ~/.npmrc
60+
//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
61+
EOF
62+
63+
# Install dependencies
64+
pnpm install
65+
66+
# Install tsx globally
67+
npm install -g tsx
68+
69+
if [ "${{ inputs.latest }}" = "true" ]; then
70+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --setupCi
71+
else
72+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --setupCi
73+
fi
7474
7575
binaries:
7676
name: "Build & Push Binaries"
77-
# needs: [setup]
77+
needs: [setup]
7878
strategy:
7979
matrix:
8080
include:
@@ -149,7 +149,7 @@ jobs:
149149
150150
docker:
151151
name: "Build & Push Docker Images"
152-
# needs: [setup]
152+
needs: [setup]
153153
strategy:
154154
matrix:
155155
include:
@@ -215,32 +215,40 @@ jobs:
215215
# secret-files: |
216216
# netrc=${{ runner.temp }}/netrc
217217

218-
# complete:
219-
# name: "Complete"
220-
# needs: [docker]
221-
# runs-on: ubuntu-24.04
222-
# steps:
223-
# - uses: actions/checkout@v4
224-
# with:
225-
# lfs: 'true'
226-
227-
# - uses: ./.github/actions/docker-setup
228-
# with:
229-
# docker_username: ${{ secrets.DOCKER_CI_USERNAME }}
230-
# docker_password: ${{ secrets.DOCKER_CI_ACCESS_TOKEN }}
231-
# github_token: ${{ secrets.GITHUB_TOKEN}}
232-
233-
# - name: Complete
234-
# env:
235-
# R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
236-
# R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
237-
# run: |
238-
# # Install Deno
239-
# curl -fsSL https://deno.land/x/install/install.sh | sh
240-
# export PATH=$HOME/.deno/bin:$PATH
241-
242-
# if [ "${{ inputs.latest }}" = "true" ]; then
243-
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --completeCi
244-
# else
245-
# ./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --completeCi
246-
# fi
218+
complete:
219+
name: "Complete"
220+
needs: [docker]
221+
runs-on: ubuntu-24.04
222+
steps:
223+
- uses: actions/checkout@v4
224+
with:
225+
lfs: 'true'
226+
227+
- uses: actions/setup-node@v4
228+
with:
229+
node-version: 20
230+
231+
- run: corepack enable
232+
233+
- uses: ./.github/actions/docker-setup
234+
with:
235+
docker_username: ${{ secrets.DOCKER_CI_USERNAME }}
236+
docker_password: ${{ secrets.DOCKER_CI_ACCESS_TOKEN }}
237+
github_token: ${{ secrets.GITHUB_TOKEN}}
238+
239+
- name: Complete
240+
env:
241+
R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
242+
R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
243+
run: |
244+
# Install dependencies
245+
pnpm install
246+
247+
# Install tsx globally
248+
npm install -g tsx
249+
250+
if [ "${{ inputs.latest }}" = "true" ]; then
251+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --completeCi
252+
else
253+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --completeCi
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
}

0 commit comments

Comments
 (0)