Skip to content

Commit

Permalink
chore(release): remove goreleaser (#9918)
Browse files Browse the repository at this point in the history
### Description

Third try is the charm. See
#9905 and
#9909 for details.

Additional changes:
- Make sure `turbo` binaries are marked as executable. Since they get
downloaded via `@actions/download-artifact` which strips permissions:
[docs](https://github.com/actions/download-artifact?tab=readme-ov-file#permission-loss)
- Correctly set `os: ["win32"]` for the windows package for
`turbo-windows-${arch}`

### Testing Instructions

Changes from previous PRs: added an e2e test to make sure that the
tarball is installable and the included executable is just that.
  • Loading branch information
chris-olszewski authored Feb 10, 2025
1 parent ee5dc12 commit ba14fce
Show file tree
Hide file tree
Showing 29 changed files with 771 additions and 166 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/turborepo-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,6 @@ jobs:
git config --global user.name 'Turbobot'
git config --global user.email '[email protected]'
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: v1.18.2
install-only: true
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Download Rust artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -242,14 +233,13 @@ jobs:
mv rust-artifacts/turbo-aarch64-apple-darwin cli/dist-darwin-arm64
mv rust-artifacts/turbo-aarch64-unknown-linux-musl cli/dist-linux-arm64
cp -r rust-artifacts/turbo-x86_64-pc-windows-msvc cli/dist-windows-arm64
mv rust-artifacts/turbo-x86_64-unknown-linux-musl cli/dist-linux-amd64
mv rust-artifacts/turbo-x86_64-apple-darwin cli/dist-darwin-amd64
mv rust-artifacts/turbo-x86_64-pc-windows-msvc cli/dist-windows-amd64
mv rust-artifacts/turbo-x86_64-unknown-linux-musl cli/dist-linux-x64
mv rust-artifacts/turbo-x86_64-apple-darwin cli/dist-darwin-x64
mv rust-artifacts/turbo-x86_64-pc-windows-msvc cli/dist-windows-x64
- name: Perform Release
run: cd cli && make publish-turbo SKIP_PUBLISH=${{ inputs.dry_run && '--skip-publish' || '' }}
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Upload published artifacts in case they are needed for debugging later
Expand Down
3 changes: 1 addition & 2 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ publish-turbo: build
npm config set --location=project "//registry.npmjs.org/:_authToken" $(NPM_TOKEN)

# Publishes the native npm modules.
# TODO: do this without goreleaser.
goreleaser release --rm-dist -f combined-shim.yml $(SKIP_PUBLISH)
turbo release-native -- $(SKIP_PUBLISH)

# Split packing from the publish step so that npm locates the correct .npmrc file.
cd $(CLI_DIR)/../packages/turbo && pnpm pack --pack-destination=$(CLI_DIR)/../
Expand Down
78 changes: 0 additions & 78 deletions cli/combined-shim.yml

This file was deleted.

6 changes: 5 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"scripts": {
"clean": "cargo clean --package turbo",
"build": "cargo build --package turbo",
"build:release": "cargo build --package turbo --profile release-turborepo"
"build:release": "cargo build --package turbo --profile release-turborepo",
"release-native": "turboreleaser --version-path ../version.txt"
},
"dependencies": {
"@turbo/releaser": "workspace:*"
}
}
1 change: 0 additions & 1 deletion cli/scripts/npm-native-packages/.gitignore

This file was deleted.

51 changes: 0 additions & 51 deletions cli/scripts/npm-native-packages/npm-native-packages.js

This file was deleted.

12 changes: 0 additions & 12 deletions cli/scripts/npm-native-packages/template/template.package.json

This file was deleted.

4 changes: 4 additions & 0 deletions cli/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY"
]
},
"release-native": {
"dependsOn": ["@turbo/releaser#build"],
"cache": false
}
}
}
26 changes: 26 additions & 0 deletions packages/turbo-releaser/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
extends: ["@turbo/eslint-config/library"],
overrides: [
{
files: ["src/*.ts", "cli/index.cjs"],
rules: {
"no-console": "off",
},
},
{
files: ["src/native.ts", "src/operations.ts"],
rules: {
"import/no-default-export": "off",
},
},
{
files: ["src/*.test.ts"],
rules: {
// https://github.com/nodejs/node/issues/51292
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
},
},
],
};
20 changes: 20 additions & 0 deletions packages/turbo-releaser/cli/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const { spawnSync } = require("node:child_process");
const path = require("node:path");

const PATH_TO_DIST = path.resolve(__dirname, "../dist");

// Define the path to the CLI file
const cliPath = path.resolve(__dirname, PATH_TO_DIST, "index.js");

try {
const result = spawnSync("node", [cliPath, ...process.argv.slice(2)], {
stdio: "inherit",
});

process.exit(result.status);
} catch (error) {
console.error("Error loading turboreleaser CLI, please re-install", error);
process.exit(1);
}
32 changes: 32 additions & 0 deletions packages/turbo-releaser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@turbo/releaser",
"private": true,
"version": "0.0.1",
"bin": {
"turboreleaser": "cli/index.cjs"
},
"files": [
"dist",
"template"
],
"scripts": {
"build": "tsup",
"check-types": "tsc --noEmit",
"test": "node --import tsx --test src/*.test.ts",
"lint": "eslint src/",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"dependencies": {
"commander": "^11.0.0",
"tar": "6.1.13"
},
"devDependencies": {
"@turbo/eslint-config": "workspace:*",
"@turbo/tsconfig": "workspace:*",
"@types/node": "^20",
"@types/tar": "^6.1.4",
"typescript": "5.5.4",
"tsup": "^6.7.0",
"tsx": "4.19.1"
}
}
54 changes: 54 additions & 0 deletions packages/turbo-releaser/src/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import path from "node:path";
import { tmpdir, arch as osArch, platform } from "node:os";
import { mkdir, realpath, rm, writeFile } from "node:fs/promises";
import { execSync } from "node:child_process";
import operations from "./operations";
import type { SupportedOS, SupportedArch } from "./types";

test("produces installable archive", async () => {
const tempDir = path.join(await realpath(tmpdir()), "turboreleaser-e2e-test");
await rm(tempDir, { recursive: true, force: true });
await mkdir(tempDir, { recursive: true });

// Need to match actual values otherwise npm will refuse to run
const os = platform() as SupportedOS;
const arch = osArch() as SupportedArch;

// make a fake turbo binary
const platformPath = `dist-${os}-${arch}`;
await mkdir(path.join(tempDir, platformPath));
await writeFile(
path.join(tempDir, platformPath, "turbo"),
"#!/bin/bash\necho Invoked fake turbo!"
);

const tarPath = await operations.packPlatform({
platform: { os, arch },
version: "0.1.2",
srcDir: tempDir,
});
assert.ok(path.isAbsolute(tarPath));

// Make a fake repo to install the tarball in
const fakeRepo = path.join(tempDir, "fake-repo");
await mkdir(fakeRepo);
await writeFile(
path.join(fakeRepo, "package.json"),
JSON.stringify({
name: "fake-repo",
scripts: { "test-turbo-install": "turbo" },
})
);
execSync(`npm install ${tarPath}`, { cwd: fakeRepo });
const output = execSync("npm run test-turbo-install", {
stdio: "pipe",
cwd: fakeRepo,
encoding: "utf-8",
});
assert.equal(
output,
"\n> test-turbo-install\n> turbo\n\nInvoked fake turbo!\n"
);
});
45 changes: 45 additions & 0 deletions packages/turbo-releaser/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Command } from "commander";
import { packAndPublish } from "./packager";
import type { Platform } from "./types";
import { getVersionInfo } from "./version";

const supportedPlatforms: Array<Platform> = [
{ os: "darwin", arch: "x64" },
{ os: "darwin", arch: "arm64" },
{ os: "linux", arch: "x64" },
{ os: "linux", arch: "arm64" },
{ os: "windows", arch: "x64" },
{ os: "windows", arch: "arm64" },
];

const turboReleaser = new Command();
turboReleaser
.requiredOption("--version-path <path>", "Path to the version.txt file")
.option("--skip-publish", "Skip publishing to NPM")
.action(main);

async function main(options: { skipPublish: boolean; versionPath: string }) {
console.log("Command line options:", options);
console.log("Supported platforms:", supportedPlatforms);

try {
const { version, npmTag } = await getVersionInfo(options.versionPath);
console.log(`Using version: ${version}, NPM tag: ${npmTag}`);

await packAndPublish({
platforms: supportedPlatforms,
version,
skipPublish: options.skipPublish as boolean,
npmTag,
});
console.log("Packaging and publishing completed successfully");
} catch (error) {
console.error("Error during packaging and publishing:", error);
process.exit(1);
}
}

turboReleaser.parseAsync().catch((reason) => {
console.error("Unexpected error. Please report it as a bug:", reason);
process.exit(1);
});
Loading

0 comments on commit ba14fce

Please sign in to comment.