Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ jobs:
test -f bin/gh-attach-darwin-arm64
test -f bin/gh-attach-windows-amd64.exe
- run: npm test
env:
GH_ATTACH_BUILD_VERSION: ${{ needs.next-version.outputs.version }}
- name: Release
run: npx semantic-release
env:
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const ROOT = resolve(import.meta.dirname, "../..");
const CJS_PATH = resolve(ROOT, "dist/cli-pkg.cjs");
const BIN_PATH = resolve(ROOT, "bin/gh-attach-linux-amd64");
const TEST_IMAGE_PATH = join(import.meta.dirname, "../fixtures/test-image.png");
const EXPECTED_VERSION =
process.env.GH_ATTACH_BUILD_VERSION ??
JSON.parse(readFileSync(resolve(ROOT, "package.json"), "utf8")).version;

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
const E2E_TEST_REPO = process.env.E2E_TEST_REPO;
Expand Down Expand Up @@ -67,10 +70,7 @@ describe("Binary Distribution E2E", () => {
const output = execSync(`${BIN_PATH} --version`, {
encoding: "utf8",
}).trim();
const pkgVersion = JSON.parse(
readFileSync(resolve(ROOT, "package.json"), "utf8"),
).version;
expect(output).toBe(pkgVersion);
expect(output).toBe(EXPECTED_VERSION);
});

it("uploads a file via release-asset strategy", () => {
Expand Down
15 changes: 6 additions & 9 deletions test/integration/cli/binary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { resolve } from "path";
const ROOT = resolve(import.meta.dirname, "../../..");
const CJS_PATH = resolve(ROOT, "dist/cli-pkg.cjs");
const ESM_PATH = resolve(ROOT, "dist/cli.js");
const EXPECTED_VERSION =
process.env.GH_ATTACH_BUILD_VERSION ??
JSON.parse(readFileSync(resolve(ROOT, "package.json"), "utf8")).version;

/**
* Runs the CJS bundle with given arguments and returns stdout.
Expand All @@ -30,12 +33,9 @@ describe("CJS Bundle (pkg target)", () => {
expect(firstLines).not.toMatch(/^import\s+\{/m);
});

it("should output version matching package.json", () => {
const pkgVersion = JSON.parse(
readFileSync(resolve(ROOT, "package.json"), "utf8"),
).version;
it("should output version matching the build version", () => {
const output = runCjs("--version");
expect(output).toBe(pkgVersion);
expect(output).toBe(EXPECTED_VERSION);
});

it("should display help text", () => {
Expand Down Expand Up @@ -90,10 +90,7 @@ describe("Binary Artifacts", () => {
const output = execSync(`${binPath} --version`, {
encoding: "utf8",
}).trim();
const pkgVersion = JSON.parse(
readFileSync(resolve(ROOT, "package.json"), "utf8"),
).version;
expect(output).toBe(pkgVersion);
expect(output).toBe(EXPECTED_VERSION);
});

it("should produce Linux binary that can display help", () => {
Expand Down
4 changes: 3 additions & 1 deletion test/integration/cli/ghExtension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const PACKAGE_JSON = JSON.parse(
) as {
version: string;
};
const EXPECTED_VERSION =
process.env.GH_ATTACH_BUILD_VERSION ?? PACKAGE_JSON.version;
const HAS_GH =
spawnSync("gh", ["--version"], {
encoding: "utf8",
Expand Down Expand Up @@ -77,7 +79,7 @@ describe("GitHub CLI extension integration", () => {
runGh(["extension", "install", "."], { cwd: ROOT, env });

expect(runGh(["attach", "--version"], { cwd: ROOT, env })).toBe(
PACKAGE_JSON.version,
EXPECTED_VERSION,
);
expect(runGh(["attach", "--help"], { cwd: ROOT, env })).toContain(
"upload",
Expand Down