From 064b3f24e66c107c2fe01290c0666798a324ed55 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 12:50:08 +0100 Subject: [PATCH 01/41] chore: add publish npm action --- .github/workflows/publish.yml | 53 +++++++ .github/workflows/release.yml | 2 +- packages/@pglt/pglt/package.json | 45 ++++++ .../@pglt/pglt/scripts/generate-packages.mjs | 137 ++++++++++++++++++ 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml create mode 100644 packages/@pglt/pglt/package.json create mode 100644 packages/@pglt/pglt/scripts/generate-packages.mjs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..f5d8817a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,53 @@ +name: Publish to NPM & Brew + +on: + workflow_dispatch: + release: + types: [released] + +jobs: + get_release_tag: + name: Get Latest Release Tag + runs-on: ubuntu-latest + outputs: + tagName: ${{ steps.get-tag-name.outputs.result }} + steps: + - uses: actions/github-script@v7 + id: get-tag-name + with: + # result-encoding: string + retries: 3 + script: | + const release = octokit.rest.repos.getLatestRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + + return { + tagName: release.tag_name, + assetsUrl: release.assets_url, + } + + publish: + name: Publish All the Things + needs: get_release_tag + runs-on: ubuntu-latest + # todo: add secrets + permissions: + contents: write + # ? what's this?! required for executing the node script? + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: lts + registry-url: "https://registry.npmjs.org" + - name: Generate Packages + run: node //todo + + - name: Publish npm packages as latest + run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4bc1b90..882dd01d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,7 +130,7 @@ jobs: fail_on_unmatched_files: true draft: true - - name: ✅ Output Link to Worflow Summary + - name: ✅ Output Link to Workflow Summary run: | { echo "# 🚀 Release completed!" diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json new file mode 100644 index 00000000..1a680f1d --- /dev/null +++ b/packages/@pglt/pglt/package.json @@ -0,0 +1,45 @@ +{ + "name": "pglt", + "version": "0.1.0", + "bin": { + "pglt": "bin/pglt" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/supabase/postgres_lsp.git", + "directory": "packages/@pglt/pglt" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Philipp Steinrötter", + "contributors": [ + { + "name": "Julian Domke", + "url": "https://github.com/juleswritescode" + } + ], + "license": "MIT or Apache-2.0", + "description": "", + "files": [ + "bin/biome", + "config_schema.json", + "README.md", + "LICENSE-APACHE", + "LICENSE-MIT", + "ROME-LICENSE-MIT" + ], + "engines": { + "node": ">=20" + }, + "optionalDependencies": { + "@pglt/cli-win32-x64": "1.9.4", + "@pglt/cli-win32-arm64": "1.9.4", + "@pglt/cli-darwin-x64": "1.9.4", + "@pglt/cli-darwin-arm64": "1.9.4", + "@pglt/cli-linux-x64": "1.9.4", + "@pglt/cli-linux-arm64": "1.9.4", + "@pglt/cli-linux-x64-musl": "1.9.4", + "@pglt/cli-linux-arm64-musl": "1.9.4" + } +} diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs new file mode 100644 index 00000000..3fbec9e1 --- /dev/null +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -0,0 +1,137 @@ +import assert from "node:assert"; +import * as fs from "node:fs"; +import { resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { format } from "node:util"; + +const CLI_ROOT = resolve(fileURLToPath(import.meta.url), "../.."); +const PACKAGES_PGLT_ROOT = resolve(CLI_ROOT, ".."); +const PGLT_ROOT = resolve(PACKAGES_PGLT_ROOT, "../.."); +const MANIFEST_PATH = resolve(CLI_ROOT, "package.json"); + +async function downloadAsset(platform, os, arch, releaseTag, githubToken) { + const buildName = getBuildName(platform, arch); + const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; + + const response = await fetch(assetUrl, { + headers: { + Authorization: `token ${githubToken}`, + Accept: `application/octet-stream`, + }, + }); + + if (!response.ok) { + throw new Error(`Failed to Fetch Asset from ${assetUrl}`); + } + + const fileStream = fs.createWriteStream(getBinarySource(os, platform, arch)); + + await new Promise((res, rej) => { + response.body.pipeTo(fileStream); + fileStream.on("error", rej); + fileStream.on("finish", res); + }); + + console.log(`Downloaded asset for ${buildName} (v${releaseTag})`); +} + +const rootManifest = JSON.parse( + fs.readFileSync(MANIFEST_PATH).toString("utf-8") +); + +function getBinaryExt(os) { + return os === "windows" ? ".exe" : ""; +} + +function getBinarySource(os, platform, arch) { + const ext = getBinaryExt(os); + return resolve(PGLT_ROOT, `${getBuildName(platform, arch)}${ext}`); +} + +function getBuildName(platform, arch) { + return format(`pglt_${arch}_${platform}`, arch); +} + +function getPackageName(platform, arch) { + // trim the "unknwown" from linux + const name = platform.split("-").slice(-2).join("-"); + return format(`@pglt/cli_${name}`, arch); +} + +function copyBinaryToNativePackage(platform, arch) { + const buildName = getBuildName(platform, arch); + const packageRoot = resolve(PACKAGES_PGLT_ROOT, buildName); + const packageName = getPackageName(platform, arch); + + // "unknow-linux-gnu", "apple-darwin" – take linux, apple, windows + const os = platform.split("-").find((_, idx) => idx === 1); + + // Update the package.json manifest + const { version, license, repository, engines } = rootManifest; + + const manifest = JSON.stringify( + { + name: packageName, + version, + license, + repository, + engines, + os: [os], + cpu: [arch], + libc: (() => { + switch (os) { + case "linux": + return "gnu"; + case "windows": + return "msvc"; + default: + return undefined; + } + })(), + }, + null, + 2 + ); + + const manifestPath = resolve(packageRoot, "package.json"); + console.info(`Update manifest ${manifestPath}`); + fs.writeFileSync(manifestPath, manifest); + + // Copy the CLI binary + const binarySource = getBinarySource(os, platform, arch); + const ext = getBinaryExt(os); + const binaryTarget = resolve(packageRoot, `pglt${ext}`); + + if (!fs.existsSync(binarySource)) { + console.error( + `Source for binary for ${buildName} not found at: ${binarySource}` + ); + process.exit(1); + } + + console.info(`Copy binary ${binaryTarget}`); + fs.copyFileSync(binarySource, binaryTarget); + fs.chmodSync(binaryTarget, 0o755); +} + +(async function main() { + const githubToken = process.env.GITHUB_TOKEN; + const assetsUrl = process.env.ASSETS_URL; + const releaseTag = process.env.RELEASE_TAG; + + assert(githubToken, "GITHUB_TOKEN not defined!"); + assert(assetsUrl, "ASSETS_URL not defined!"); + assert(releaseTag, "RELEASE_TAG not defined!"); + + const PLATFORMS = ["windows-msvc", "apple-darwin", "unknown-linux-gnu"]; + const ARCHITECTURES = ["x86_64", "aarch64"]; + + for (const platform of PLATFORMS) { + for (const arch of ARCHITECTURES) { + await downloadAsset(platform, os, arch, releaseTag, githubToken); + copyBinaryToNativePackage(platform, arch); + } + } + + process.exit(0); +})(); From a9f36e7ebbda3b0df54f989c8c8499bf2ca77869 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 12:53:41 +0100 Subject: [PATCH 02/41] don't have that yet --- packages/@pglt/pglt/package.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index 1a680f1d..25fc1bd9 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -22,12 +22,8 @@ "license": "MIT or Apache-2.0", "description": "", "files": [ - "bin/biome", - "config_schema.json", - "README.md", - "LICENSE-APACHE", - "LICENSE-MIT", - "ROME-LICENSE-MIT" + "bin/pglt", + "config_schema.json" ], "engines": { "node": ">=20" From 3e24df44b1732e785f578a8f8510ea7c5c1aa27c Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:01:02 +0100 Subject: [PATCH 03/41] copy that schema --- packages/@pglt/pglt/package.json | 2 +- .../@pglt/pglt/scripts/generate-packages.mjs | 49 ++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index 25fc1bd9..0f9b533d 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -23,7 +23,7 @@ "description": "", "files": [ "bin/pglt", - "config_schema.json" + "schema.json" ], "engines": { "node": ">=20" diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 3fbec9e1..a9909f89 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -9,6 +9,32 @@ const PACKAGES_PGLT_ROOT = resolve(CLI_ROOT, ".."); const PGLT_ROOT = resolve(PACKAGES_PGLT_ROOT, "../.."); const MANIFEST_PATH = resolve(CLI_ROOT, "package.json"); +async function downloadSchema(releaseTag, githubToken) { + const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/schema.json`; + + const response = await fetch(assetUrl, { + headers: { + Authorization: `token ${githubToken}`, + Accept: `application/octet-stream`, + }, + }); + + if (!response.ok) { + throw new Error(`Failed to Fetch Asset from ${assetUrl}`); + } + + // download to root. + const fileStream = fs.createWriteStream(resolve(PGLT_ROOT, "schema.json")); + + await new Promise((res, rej) => { + response.body.pipeTo(fileStream); + fileStream.on("error", rej); + fileStream.on("finish", res); + }); + + console.log(`Downloaded schema for ${releaseTag}`); +} + async function downloadAsset(platform, os, arch, releaseTag, githubToken) { const buildName = getBuildName(platform, arch); const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; @@ -24,6 +50,7 @@ async function downloadAsset(platform, os, arch, releaseTag, githubToken) { throw new Error(`Failed to Fetch Asset from ${assetUrl}`); } + // just download to root. const fileStream = fs.createWriteStream(getBinarySource(os, platform, arch)); await new Promise((res, rej) => { @@ -114,15 +141,32 @@ function copyBinaryToNativePackage(platform, arch) { fs.chmodSync(binaryTarget, 0o755); } +function copySchemaToNativePackage(platform, arch) { + const buildName = getBuildName(platform, arch); + const packageRoot = resolve(PACKAGES_PGLT_ROOT, buildName); + + const schemaSrc = resolve(packageRoot, `schema.json`); + const schemaTarget = resolve(packageRoot, `schema.json`); + + if (!fs.existsSync(schemaSrc)) { + console.error(`Schema.json not found at: ${schemaSrc}`); + process.exit(1); + } + + console.info(`Copying schema.json`); + fs.copyFileSync(schemaSrc, schemaTarget); + fs.chmodSync(schemaTarget, 0o666); +} + (async function main() { const githubToken = process.env.GITHUB_TOKEN; - const assetsUrl = process.env.ASSETS_URL; const releaseTag = process.env.RELEASE_TAG; assert(githubToken, "GITHUB_TOKEN not defined!"); - assert(assetsUrl, "ASSETS_URL not defined!"); assert(releaseTag, "RELEASE_TAG not defined!"); + await downloadSchema(releaseTag, githubToken); + const PLATFORMS = ["windows-msvc", "apple-darwin", "unknown-linux-gnu"]; const ARCHITECTURES = ["x86_64", "aarch64"]; @@ -130,6 +174,7 @@ function copyBinaryToNativePackage(platform, arch) { for (const arch of ARCHITECTURES) { await downloadAsset(platform, os, arch, releaseTag, githubToken); copyBinaryToNativePackage(platform, arch); + copySchemaToNativePackage(platform, arch); } } From 4afd7925cf7c35747a424ea1c148dd506246a666 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:08:42 +0100 Subject: [PATCH 04/41] add thangs --- packages/@pglt/pglt_aarch64-apple-darwin/package.json | 1 + packages/@pglt/pglt_aarch64-pc-windows-msvc/package.json | 1 + packages/@pglt/pglt_aarch64-unknown-linux-gnu/package.json | 1 + packages/@pglt/pglt_x86_64-apple-darwin/package.json | 1 + packages/@pglt/pglt_x86_64-pc-windows-msvc/package.json | 1 + packages/@pglt/pglt_x86_64-unknown-linux-gnu/package.json | 1 + 6 files changed, 6 insertions(+) create mode 100644 packages/@pglt/pglt_aarch64-apple-darwin/package.json create mode 100644 packages/@pglt/pglt_aarch64-pc-windows-msvc/package.json create mode 100644 packages/@pglt/pglt_aarch64-unknown-linux-gnu/package.json create mode 100644 packages/@pglt/pglt_x86_64-apple-darwin/package.json create mode 100644 packages/@pglt/pglt_x86_64-pc-windows-msvc/package.json create mode 100644 packages/@pglt/pglt_x86_64-unknown-linux-gnu/package.json diff --git a/packages/@pglt/pglt_aarch64-apple-darwin/package.json b/packages/@pglt/pglt_aarch64-apple-darwin/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/packages/@pglt/pglt_aarch64-apple-darwin/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/@pglt/pglt_aarch64-pc-windows-msvc/package.json b/packages/@pglt/pglt_aarch64-pc-windows-msvc/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/packages/@pglt/pglt_aarch64-pc-windows-msvc/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/@pglt/pglt_aarch64-unknown-linux-gnu/package.json b/packages/@pglt/pglt_aarch64-unknown-linux-gnu/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/packages/@pglt/pglt_aarch64-unknown-linux-gnu/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/@pglt/pglt_x86_64-apple-darwin/package.json b/packages/@pglt/pglt_x86_64-apple-darwin/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/packages/@pglt/pglt_x86_64-apple-darwin/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/@pglt/pglt_x86_64-pc-windows-msvc/package.json b/packages/@pglt/pglt_x86_64-pc-windows-msvc/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/packages/@pglt/pglt_x86_64-pc-windows-msvc/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/@pglt/pglt_x86_64-unknown-linux-gnu/package.json b/packages/@pglt/pglt_x86_64-unknown-linux-gnu/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/packages/@pglt/pglt_x86_64-unknown-linux-gnu/package.json @@ -0,0 +1 @@ +{} From 125f8fc772a1c0be663eb00a75e1b3aa5559df7d Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:10:01 +0100 Subject: [PATCH 05/41] ok? --- packages/@pglt/pglt/package.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index 0f9b533d..8374f37d 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -29,13 +29,11 @@ "node": ">=20" }, "optionalDependencies": { - "@pglt/cli-win32-x64": "1.9.4", - "@pglt/cli-win32-arm64": "1.9.4", - "@pglt/cli-darwin-x64": "1.9.4", - "@pglt/cli-darwin-arm64": "1.9.4", - "@pglt/cli-linux-x64": "1.9.4", - "@pglt/cli-linux-arm64": "1.9.4", - "@pglt/cli-linux-x64-musl": "1.9.4", - "@pglt/cli-linux-arm64-musl": "1.9.4" + "@pglt/cli-aarch64-apple-darwin": "0.1.0", + "@pglt/cli-aarch64-pc-windows-msvc": "0.1.0", + "@pglt/cli-aarch64-unknown-linux-gnu": "0.1.0", + "@pglt/cli-x86_64-apple-darwin": "0.1.0", + "@pglt/cli-x86_64-pc-windows-msvc": "0.1.0", + "@pglt/cli-x86_64-unknown-linux-gnu": "0.1.0" } } From 6baf503b0784c701f1ddb5ec1485d3487e937ff4 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:10:44 +0100 Subject: [PATCH 06/41] trim names --- packages/@pglt/pglt/package.json | 11 ++++------- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index 8374f37d..8f507573 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -9,9 +9,6 @@ "url": "git+https://github.com/supabase/postgres_lsp.git", "directory": "packages/@pglt/pglt" }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "author": "Philipp Steinrötter", "contributors": [ { @@ -30,10 +27,10 @@ }, "optionalDependencies": { "@pglt/cli-aarch64-apple-darwin": "0.1.0", - "@pglt/cli-aarch64-pc-windows-msvc": "0.1.0", - "@pglt/cli-aarch64-unknown-linux-gnu": "0.1.0", + "@pglt/cli-aarch64-windows-msvc": "0.1.0", + "@pglt/cli-aarch64-linux-gnu": "0.1.0", "@pglt/cli-x86_64-apple-darwin": "0.1.0", - "@pglt/cli-x86_64-pc-windows-msvc": "0.1.0", - "@pglt/cli-x86_64-unknown-linux-gnu": "0.1.0" + "@pglt/cli-x86_64-windows-msvc": "0.1.0", + "@pglt/cli-x86_64-linux-gnu": "0.1.0" } } diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index a9909f89..b380038a 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -80,7 +80,7 @@ function getBuildName(platform, arch) { } function getPackageName(platform, arch) { - // trim the "unknwown" from linux + // trim the "unknown" from linux const name = platform.split("-").slice(-2).join("-"); return format(`@pglt/cli_${name}`, arch); } From 6b0aa3d64a8711858927cf1f95867f7db9e62936 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:21:47 +0100 Subject: [PATCH 07/41] debug thing --- .github/workflows/publish.dispatch.yml | 17 +++++++++ .github/workflows/publish.reusable.yml | 44 +++++++++++++++++++++ .github/workflows/publish.yml | 53 -------------------------- 3 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/publish.dispatch.yml create mode 100644 .github/workflows/publish.reusable.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.dispatch.yml b/.github/workflows/publish.dispatch.yml new file mode 100644 index 00000000..77dd2aa9 --- /dev/null +++ b/.github/workflows/publish.dispatch.yml @@ -0,0 +1,17 @@ +name: Publish NPM (Dispatch) + +on: + workflow_dispatch: + inputs: + release_tag: + type: string + required: true + description: Release Tag to Publish + +jobs: + publish_npm: + uses: ./.github/workflows/publish.reusable.yml + with: + release-tag: ${{ github.event.inputs.release_tag }} + secrets: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml new file mode 100644 index 00000000..efcc6877 --- /dev/null +++ b/.github/workflows/publish.reusable.yml @@ -0,0 +1,44 @@ +name: Publish to NPM & Brew + +on: + workflow_call: + inputs: + release-tag: + type: string + required: true + secrets: + github_token: + required: true + +jobs: + publish: + name: Publish All the Things + runs-on: ubuntu-latest + # todo: add secrets + permissions: + contents: write + # ? what's this?! required for executing the node script? + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: lts + registry-url: "https://registry.npmjs.org" + + - name: Generate Packages + run: node packages/@pglt/pglt/scripts/generate-packages.mjs + + - name: DEBUG - log assets + run: | + { + ls packages/@pglt/pglt_aarch64_pc-windows-msvc + cat packages/@pglt/pglt_aarch64_pc-windows-msvc/package.json + } + + # - name: Publish npm packages as latest + # run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index f5d8817a..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Publish to NPM & Brew - -on: - workflow_dispatch: - release: - types: [released] - -jobs: - get_release_tag: - name: Get Latest Release Tag - runs-on: ubuntu-latest - outputs: - tagName: ${{ steps.get-tag-name.outputs.result }} - steps: - - uses: actions/github-script@v7 - id: get-tag-name - with: - # result-encoding: string - retries: 3 - script: | - const release = octokit.rest.repos.getLatestRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - }); - - return { - tagName: release.tag_name, - assetsUrl: release.assets_url, - } - - publish: - name: Publish All the Things - needs: get_release_tag - runs-on: ubuntu-latest - # todo: add secrets - permissions: - contents: write - # ? what's this?! required for executing the node script? - id-token: write - steps: - - uses: actions/checkout@v4 - - name: Install Node - uses: actions/setup-node@v4 - with: - node-version: lts - registry-url: "https://registry.npmjs.org" - - name: Generate Packages - run: node //todo - - - name: Publish npm packages as latest - run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From eaf309774ad3cab368c45bdaf2603a2a6475195d Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:23:52 +0100 Subject: [PATCH 08/41] ok? --- .github/workflows/publish.reusable.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index efcc6877..a01579b5 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -14,6 +14,7 @@ jobs: publish: name: Publish All the Things runs-on: ubuntu-latest + # todo: add secrets permissions: contents: write @@ -30,6 +31,9 @@ jobs: - name: Generate Packages run: node packages/@pglt/pglt/scripts/generate-packages.mjs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_TAG: ${{ inputs.release-tag }} - name: DEBUG - log assets run: | From 0ce8fa3a32bb6d05f39d4c526d322c2c209f94ac Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:25:47 +0100 Subject: [PATCH 09/41] changy change --- packages/@pglt/pglt/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index 8f507573..3b7b1ba1 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -9,8 +9,12 @@ "url": "git+https://github.com/supabase/postgres_lsp.git", "directory": "packages/@pglt/pglt" }, - "author": "Philipp Steinrötter", + "author": "Supabase Community", "contributors": [ + { + "name": "Philipp Steinrötter", + "url": "https://github.com/psteinroe" + }, { "name": "Julian Domke", "url": "https://github.com/juleswritescode" From f63de176da4b10fff4c60cf821dc35774452035a Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:27:28 +0100 Subject: [PATCH 10/41] like so? --- .github/workflows/publish.dispatch.yml | 3 +-- .github/workflows/publish.reusable.yml | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/publish.dispatch.yml b/.github/workflows/publish.dispatch.yml index 77dd2aa9..d07a80cd 100644 --- a/.github/workflows/publish.dispatch.yml +++ b/.github/workflows/publish.dispatch.yml @@ -13,5 +13,4 @@ jobs: uses: ./.github/workflows/publish.reusable.yml with: release-tag: ${{ github.event.inputs.release_tag }} - secrets: - github_token: ${{ secrets.GITHUB_TOKEN }} + secrets: inherit diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index a01579b5..349704c1 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -6,9 +6,6 @@ on: release-tag: type: string required: true - secrets: - github_token: - required: true jobs: publish: From d7cf708ac19c1a310e56e18d7d275a2fecf64fd9 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:30:04 +0100 Subject: [PATCH 11/41] make it test --- .github/workflows/publish.reusable.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 349704c1..8360d927 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -1,11 +1,10 @@ name: Publish to NPM & Brew on: - workflow_call: - inputs: - release-tag: - type: string - required: true + pull_request: + branches: + - juleswritescode:chore/add-publish-action + - chore/add-publish-action jobs: publish: @@ -30,7 +29,7 @@ jobs: run: node packages/@pglt/pglt/scripts/generate-packages.mjs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_TAG: ${{ inputs.release-tag }} + RELEASE_TAG: "0.1.0" - name: DEBUG - log assets run: | From dbe192478506870dba449448f64f146d1e586a4b Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:31:45 +0100 Subject: [PATCH 12/41] well --- .github/workflows/publish.reusable.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 8360d927..3ae8eee7 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -3,8 +3,8 @@ name: Publish to NPM & Brew on: pull_request: branches: - - juleswritescode:chore/add-publish-action - - chore/add-publish-action + - main + - supabase-community:main jobs: publish: From 9e3e092ece22dcf8cc362eebb4882c1762939090 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:32:35 +0100 Subject: [PATCH 13/41] thats not a valid alias --- .github/workflows/publish.reusable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 3ae8eee7..0193f8b4 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -22,7 +22,7 @@ jobs: - name: Install Node uses: actions/setup-node@v4 with: - node-version: lts + node-version: lts/* registry-url: "https://registry.npmjs.org" - name: Generate Packages From 711fb484599bc7b71c0b90c9af35d60073d9867c Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:37:18 +0100 Subject: [PATCH 14/41] use pipes --- .../@pglt/pglt/scripts/generate-packages.mjs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index b380038a..c24e95c1 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -1,14 +1,17 @@ import assert from "node:assert"; import * as fs from "node:fs"; +import { pipeline } from "node:stream"; import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; -import { format } from "node:util"; +import { format, promisify } from "node:util"; const CLI_ROOT = resolve(fileURLToPath(import.meta.url), "../.."); const PACKAGES_PGLT_ROOT = resolve(CLI_ROOT, ".."); const PGLT_ROOT = resolve(PACKAGES_PGLT_ROOT, "../.."); const MANIFEST_PATH = resolve(CLI_ROOT, "package.json"); +const streamPipeline = promisify(pipeline); + async function downloadSchema(releaseTag, githubToken) { const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/schema.json`; @@ -26,11 +29,7 @@ async function downloadSchema(releaseTag, githubToken) { // download to root. const fileStream = fs.createWriteStream(resolve(PGLT_ROOT, "schema.json")); - await new Promise((res, rej) => { - response.body.pipeTo(fileStream); - fileStream.on("error", rej); - fileStream.on("finish", res); - }); + await streamPipeline(response.body, fileStream); console.log(`Downloaded schema for ${releaseTag}`); } @@ -53,11 +52,7 @@ async function downloadAsset(platform, os, arch, releaseTag, githubToken) { // just download to root. const fileStream = fs.createWriteStream(getBinarySource(os, platform, arch)); - await new Promise((res, rej) => { - response.body.pipeTo(fileStream); - fileStream.on("error", rej); - fileStream.on("finish", res); - }); + await streamPipeline(response.body, fileStream); console.log(`Downloaded asset for ${buildName} (v${releaseTag})`); } From f4abd92797094058dc43bd3b5b74f230f7d56206 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:40:01 +0100 Subject: [PATCH 15/41] rework --- packages/@pglt/pglt/scripts/generate-packages.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index c24e95c1..7432b637 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -80,13 +80,16 @@ function getPackageName(platform, arch) { return format(`@pglt/cli_${name}`, arch); } -function copyBinaryToNativePackage(platform, arch) { +function getOs(platform) { + return platform.split("-").find((_, idx) => idx === 1); +} + +function copyBinaryToNativePackage(platform, arch, os) { const buildName = getBuildName(platform, arch); const packageRoot = resolve(PACKAGES_PGLT_ROOT, buildName); const packageName = getPackageName(platform, arch); // "unknow-linux-gnu", "apple-darwin" – take linux, apple, windows - const os = platform.split("-").find((_, idx) => idx === 1); // Update the package.json manifest const { version, license, repository, engines } = rootManifest; @@ -167,8 +170,9 @@ function copySchemaToNativePackage(platform, arch) { for (const platform of PLATFORMS) { for (const arch of ARCHITECTURES) { + const os = getOs(platform); await downloadAsset(platform, os, arch, releaseTag, githubToken); - copyBinaryToNativePackage(platform, arch); + copyBinaryToNativePackage(platform, arch, os); copySchemaToNativePackage(platform, arch); } } From 38e30cfd6098d1fa3658c675c60ec30e10dabddf Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:41:16 +0100 Subject: [PATCH 16/41] ocd --- packages/@pglt/pglt/scripts/generate-packages.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 7432b637..a9479c25 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -34,7 +34,7 @@ async function downloadSchema(releaseTag, githubToken) { console.log(`Downloaded schema for ${releaseTag}`); } -async function downloadAsset(platform, os, arch, releaseTag, githubToken) { +async function downloadAsset(platform, arch, os, releaseTag, githubToken) { const buildName = getBuildName(platform, arch); const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; @@ -50,7 +50,7 @@ async function downloadAsset(platform, os, arch, releaseTag, githubToken) { } // just download to root. - const fileStream = fs.createWriteStream(getBinarySource(os, platform, arch)); + const fileStream = fs.createWriteStream(getBinarySource(platform, arch, os)); await streamPipeline(response.body, fileStream); @@ -65,7 +65,7 @@ function getBinaryExt(os) { return os === "windows" ? ".exe" : ""; } -function getBinarySource(os, platform, arch) { +function getBinarySource(platform, arch, os) { const ext = getBinaryExt(os); return resolve(PGLT_ROOT, `${getBuildName(platform, arch)}${ext}`); } @@ -123,7 +123,7 @@ function copyBinaryToNativePackage(platform, arch, os) { fs.writeFileSync(manifestPath, manifest); // Copy the CLI binary - const binarySource = getBinarySource(os, platform, arch); + const binarySource = getBinarySource(platform, arch, os); const ext = getBinaryExt(os); const binaryTarget = resolve(packageRoot, `pglt${ext}`); @@ -169,9 +169,10 @@ function copySchemaToNativePackage(platform, arch) { const ARCHITECTURES = ["x86_64", "aarch64"]; for (const platform of PLATFORMS) { + const os = getOs(platform); + for (const arch of ARCHITECTURES) { - const os = getOs(platform); - await downloadAsset(platform, os, arch, releaseTag, githubToken); + await downloadAsset(platform, arch, os, releaseTag, githubToken); copyBinaryToNativePackage(platform, arch, os); copySchemaToNativePackage(platform, arch); } From 584c67af5ecc7cea7ea0ec01d78abd81bbfe487d Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:43:44 +0100 Subject: [PATCH 17/41] wrong platform name --- packages/@pglt/pglt/scripts/generate-packages.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index a9479c25..85895dcd 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -36,6 +36,9 @@ async function downloadSchema(releaseTag, githubToken) { async function downloadAsset(platform, arch, os, releaseTag, githubToken) { const buildName = getBuildName(platform, arch); + + // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64_windows-msvc + // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64-pc-windows-msvc const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; const response = await fetch(assetUrl, { @@ -165,7 +168,7 @@ function copySchemaToNativePackage(platform, arch) { await downloadSchema(releaseTag, githubToken); - const PLATFORMS = ["windows-msvc", "apple-darwin", "unknown-linux-gnu"]; + const PLATFORMS = ["pc-windows-msvc", "apple-darwin", "unknown-linux-gnu"]; const ARCHITECTURES = ["x86_64", "aarch64"]; for (const platform of PLATFORMS) { From ebd6760ca7071da307c90c68980def4f0e1e382c Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:45:32 +0100 Subject: [PATCH 18/41] debug --- packages/@pglt/pglt/scripts/generate-packages.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 85895dcd..6596aa12 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -37,7 +37,7 @@ async function downloadSchema(releaseTag, githubToken) { async function downloadAsset(platform, arch, os, releaseTag, githubToken) { const buildName = getBuildName(platform, arch); - // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64_windows-msvc + // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64_pc-windows-msvc // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64-pc-windows-msvc const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; @@ -49,7 +49,8 @@ async function downloadAsset(platform, arch, os, releaseTag, githubToken) { }); if (!response.ok) { - throw new Error(`Failed to Fetch Asset from ${assetUrl}`); + const error = await response.text(); + throw new Error(`Failed to Fetch Asset from ${assetUrl}. Reason: ${error}`); } // just download to root. From c698b4c003019e259090c5130207ca3570f46d80 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:47:10 +0100 Subject: [PATCH 19/41] well... --- packages/@pglt/pglt/scripts/generate-packages.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 6596aa12..f24125c7 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -75,13 +75,13 @@ function getBinarySource(platform, arch, os) { } function getBuildName(platform, arch) { - return format(`pglt_${arch}_${platform}`, arch); + return `pglt_${arch}_${platform}`; } function getPackageName(platform, arch) { // trim the "unknown" from linux const name = platform.split("-").slice(-2).join("-"); - return format(`@pglt/cli_${name}`, arch); + return `@pglt/cli_${arch}-${name}`; } function getOs(platform) { From 10d082297e5f704693a17e727f7eff4269187938 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:47:32 +0100 Subject: [PATCH 20/41] more sexy --- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index f24125c7..7d99711e 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -81,7 +81,7 @@ function getBuildName(platform, arch) { function getPackageName(platform, arch) { // trim the "unknown" from linux const name = platform.split("-").slice(-2).join("-"); - return `@pglt/cli_${arch}-${name}`; + return `@pglt/cli-${arch}-${name}`; } function getOs(platform) { From 92c9658107b13004664b325cb49b7b6f442ac495 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:49:37 +0100 Subject: [PATCH 21/41] thats not an underscore --- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 7d99711e..11328448 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -75,7 +75,7 @@ function getBinarySource(platform, arch, os) { } function getBuildName(platform, arch) { - return `pglt_${arch}_${platform}`; + return `pglt_${arch}-${platform}`; } function getPackageName(platform, arch) { From 348dfaf24a32eee6302fb99dedc541982260d26a Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:51:07 +0100 Subject: [PATCH 22/41] schema src --- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 11328448..823cf2ad 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -147,7 +147,7 @@ function copySchemaToNativePackage(platform, arch) { const buildName = getBuildName(platform, arch); const packageRoot = resolve(PACKAGES_PGLT_ROOT, buildName); - const schemaSrc = resolve(packageRoot, `schema.json`); + const schemaSrc = resolve(PGLT_ROOT, `schema.json`); const schemaTarget = resolve(packageRoot, `schema.json`); if (!fs.existsSync(schemaSrc)) { From d43694891655b9e91d51b3f4c616667c456caa2a Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:52:47 +0100 Subject: [PATCH 23/41] escape? --- .github/workflows/publish.reusable.yml | 4 ++-- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 0193f8b4..92e34f43 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -34,8 +34,8 @@ jobs: - name: DEBUG - log assets run: | { - ls packages/@pglt/pglt_aarch64_pc-windows-msvc - cat packages/@pglt/pglt_aarch64_pc-windows-msvc/package.json + ls packages/\@pglt/pglt_aarch64_pc-windows-msvc + cat packages/\@pglt/pglt_aarch64_pc-windows-msvc/package.json } # - name: Publish npm packages as latest diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 823cf2ad..089ce379 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -151,7 +151,7 @@ function copySchemaToNativePackage(platform, arch) { const schemaTarget = resolve(packageRoot, `schema.json`); if (!fs.existsSync(schemaSrc)) { - console.error(`Schema.json not found at: ${schemaSrc}`); + console.error(`schema.json not found at: ${schemaSrc}`); process.exit(1); } From a1607c50e4fceb8a4b369bfaf54e7af587e6c0d6 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:53:01 +0100 Subject: [PATCH 24/41] cleanup --- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 089ce379..95e09727 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -37,8 +37,6 @@ async function downloadSchema(releaseTag, githubToken) { async function downloadAsset(platform, arch, os, releaseTag, githubToken) { const buildName = getBuildName(platform, arch); - // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64_pc-windows-msvc - // https://github.com/supabase-community/postgres_lsp/releases/download/0.1.0/pglt_x86_64-pc-windows-msvc const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; const response = await fetch(assetUrl, { From c3b03b273a4f7a217be563346f894fe9bec7dbe7 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:53:33 +0100 Subject: [PATCH 25/41] herantasten --- .github/workflows/publish.reusable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 92e34f43..f61af2e8 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -34,6 +34,8 @@ jobs: - name: DEBUG - log assets run: | { + ls packages + ls packages/\@pglt ls packages/\@pglt/pglt_aarch64_pc-windows-msvc cat packages/\@pglt/pglt_aarch64_pc-windows-msvc/package.json } From bbde5f7ed24c9d54200e0c128869c7a64374368b Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:55:28 +0100 Subject: [PATCH 26/41] these underscores dang --- .github/workflows/publish.reusable.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index f61af2e8..fe539524 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -36,8 +36,8 @@ jobs: { ls packages ls packages/\@pglt - ls packages/\@pglt/pglt_aarch64_pc-windows-msvc - cat packages/\@pglt/pglt_aarch64_pc-windows-msvc/package.json + ls packages/\@pglt/pglt_aarch64-pc-windows-msvc + cat packages/\@pglt/pglt_aarch64-pc-windows-msvc/package.json } # - name: Publish npm packages as latest From 29e9dbdb84afeca461107661980b8605dfdcde6e Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 13:56:45 +0100 Subject: [PATCH 27/41] it apparently works --- .github/workflows/publish.reusable.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index fe539524..bb2ebecc 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -31,15 +31,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_TAG: "0.1.0" - - name: DEBUG - log assets - run: | - { - ls packages - ls packages/\@pglt - ls packages/\@pglt/pglt_aarch64-pc-windows-msvc - cat packages/\@pglt/pglt_aarch64-pc-windows-msvc/package.json - } - # - name: Publish npm packages as latest # run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done # env: From 9250363a6d94d626d4277c78f699e387ab79819d Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 15:02:55 +0100 Subject: [PATCH 28/41] restructure --- packages/@pglt/pglt/package.json | 14 ++-- .../@pglt/pglt/scripts/generate-packages.mjs | 80 +++++++++++-------- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index 3b7b1ba1..d14e0ba2 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -1,6 +1,6 @@ { "name": "pglt", - "version": "0.1.0", + "version": "", "bin": { "pglt": "bin/pglt" }, @@ -30,11 +30,11 @@ "node": ">=20" }, "optionalDependencies": { - "@pglt/cli-aarch64-apple-darwin": "0.1.0", - "@pglt/cli-aarch64-windows-msvc": "0.1.0", - "@pglt/cli-aarch64-linux-gnu": "0.1.0", - "@pglt/cli-x86_64-apple-darwin": "0.1.0", - "@pglt/cli-x86_64-windows-msvc": "0.1.0", - "@pglt/cli-x86_64-linux-gnu": "0.1.0" + "@pglt/cli-aarch64-apple-darwin": "", + "@pglt/cli-aarch64-windows-msvc": "", + "@pglt/cli-aarch64-linux-gnu": "", + "@pglt/cli-x86_64-apple-darwin": "", + "@pglt/cli-x86_64-windows-msvc": "", + "@pglt/cli-x86_64-linux-gnu": "" } } diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 95e09727..a44bc96a 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -3,14 +3,19 @@ import * as fs from "node:fs"; import { pipeline } from "node:stream"; import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; -import { format, promisify } from "node:util"; +import { promisify } from "node:util"; +const streamPipeline = promisify(pipeline); const CLI_ROOT = resolve(fileURLToPath(import.meta.url), "../.."); const PACKAGES_PGLT_ROOT = resolve(CLI_ROOT, ".."); const PGLT_ROOT = resolve(PACKAGES_PGLT_ROOT, "../.."); const MANIFEST_PATH = resolve(CLI_ROOT, "package.json"); - -const streamPipeline = promisify(pipeline); +const SUPPORTED_PLATFORMS = [ + "pc-windows-msvc", + "apple-darwin", + "unknown-linux-gnu", +]; +const SUPPORTED_ARCHITECTURES = ["x86_64", "aarch64"]; async function downloadSchema(releaseTag, githubToken) { const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/schema.json`; @@ -34,7 +39,7 @@ async function downloadSchema(releaseTag, githubToken) { console.log(`Downloaded schema for ${releaseTag}`); } -async function downloadAsset(platform, arch, os, releaseTag, githubToken) { +async function downloadBinary(platform, arch, os, releaseTag, githubToken) { const buildName = getBuildName(platform, arch); const assetUrl = `https://github.com/supabase-community/postgres_lsp/releases/download/${releaseTag}/${buildName}`; @@ -59,31 +64,15 @@ async function downloadAsset(platform, arch, os, releaseTag, githubToken) { console.log(`Downloaded asset for ${buildName} (v${releaseTag})`); } -const rootManifest = JSON.parse( - fs.readFileSync(MANIFEST_PATH).toString("utf-8") -); - -function getBinaryExt(os) { - return os === "windows" ? ".exe" : ""; -} +async function overwriteManifestVersions(releaseTag) { + const manifestClone = structuredClone(rootManifest); -function getBinarySource(platform, arch, os) { - const ext = getBinaryExt(os); - return resolve(PGLT_ROOT, `${getBuildName(platform, arch)}${ext}`); -} - -function getBuildName(platform, arch) { - return `pglt_${arch}-${platform}`; -} - -function getPackageName(platform, arch) { - // trim the "unknown" from linux - const name = platform.split("-").slice(-2).join("-"); - return `@pglt/cli-${arch}-${name}`; -} + manifestClone.version = releaseTag; + for (const key in manifestClone.optionalDependencies) { + manifestClone.optionalDependencies[key] = releaseTag; + } -function getOs(platform) { - return platform.split("-").find((_, idx) => idx === 1); + fs.writeFileSync(MANIFEST_PATH, JSON.stringify(manifestClone, null, 2)); } function copyBinaryToNativePackage(platform, arch, os) { @@ -158,6 +147,33 @@ function copySchemaToNativePackage(platform, arch) { fs.chmodSync(schemaTarget, 0o666); } +const rootManifest = JSON.parse( + fs.readFileSync(MANIFEST_PATH).toString("utf-8") +); + +function getBinaryExt(os) { + return os === "windows" ? ".exe" : ""; +} + +function getBinarySource(platform, arch, os) { + const ext = getBinaryExt(os); + return resolve(PGLT_ROOT, `${getBuildName(platform, arch)}${ext}`); +} + +function getBuildName(platform, arch) { + return `pglt_${arch}-${platform}`; +} + +function getPackageName(platform, arch) { + // trim the "unknown" from linux and the "pc" from windows + const name = platform.split("-").slice(-2).join("-"); + return `@pglt/cli-${arch}-${name}`; +} + +function getOs(platform) { + return platform.split("-").find((_, idx) => idx === 1); +} + (async function main() { const githubToken = process.env.GITHUB_TOKEN; const releaseTag = process.env.RELEASE_TAG; @@ -166,15 +182,13 @@ function copySchemaToNativePackage(platform, arch) { assert(releaseTag, "RELEASE_TAG not defined!"); await downloadSchema(releaseTag, githubToken); + overwriteManifestVersions(releaseTag); - const PLATFORMS = ["pc-windows-msvc", "apple-darwin", "unknown-linux-gnu"]; - const ARCHITECTURES = ["x86_64", "aarch64"]; - - for (const platform of PLATFORMS) { + for (const platform of SUPPORTED_PLATFORMS) { const os = getOs(platform); - for (const arch of ARCHITECTURES) { - await downloadAsset(platform, arch, os, releaseTag, githubToken); + for (const arch of SUPPORTED_ARCHITECTURES) { + await downloadBinary(platform, arch, os, releaseTag, githubToken); copyBinaryToNativePackage(platform, arch, os); copySchemaToNativePackage(platform, arch); } From 7a4f004f936c59f052cefc0e00e62ddedf320e68 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 15:03:44 +0100 Subject: [PATCH 29/41] ls that stuff --- .github/workflows/publish.reusable.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index bb2ebecc..f99dbfc6 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -31,6 +31,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_TAG: "0.1.0" + - name: DEBUG + run: ls packages/\@pglt/pglt/package.json + # - name: Publish npm packages as latest # run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done # env: From 59bd6432900676a45a87a533854dcc2dbcb7f774 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 15:04:41 +0100 Subject: [PATCH 30/41] cat instead --- .github/workflows/publish.reusable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index f99dbfc6..a898ab44 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -32,7 +32,7 @@ jobs: RELEASE_TAG: "0.1.0" - name: DEBUG - run: ls packages/\@pglt/pglt/package.json + run: cat packages/\@pglt/pglt/package.json # - name: Publish npm packages as latest # run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done From 7aed7f4a6b8b8f33d84fc495cfe4da4c9844d189 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 15:17:22 +0100 Subject: [PATCH 31/41] this the script? --- packages/@pglt/pglt/bin/pglt | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 packages/@pglt/pglt/bin/pglt diff --git a/packages/@pglt/pglt/bin/pglt b/packages/@pglt/pglt/bin/pglt new file mode 100644 index 00000000..06101104 --- /dev/null +++ b/packages/@pglt/pglt/bin/pglt @@ -0,0 +1,46 @@ +#!/usr/bin/env node +const { platform, arch, env } = process; + +/** + * platform and arch are values injected into the node runtime. + * We use the values documented on https://nodejs.org. + */ +const PLATFORMS = { + win32: { + x64: "@pglt/cli-x86_64-windows-msvc/pglt.exe", + arm64: "@pglt/cli-aarch64-windows-msvc/pglt.exe", + }, + darwin: { + x64: "@pglt/cli-x86_64-apple-darwin/pglt", + arm64: "@pglt/cli-aarch64-apple-darwin/pglt", + }, + linux: { + x64: "@pglt/cli-x86_64-linux-gnu/pglt", + arm64: "@pglt/cli-aarch64-linux-gnu/pglt", + }, +}; + +const binPath = env.PGLT_BINARY || PLATFORMS?.[platform]?.[arch]; + +if (binPath) { + const result = require("child_process").spawnSync( + require.resolve(binPath), + process.argv.slice(2), + { + shell: false, + stdio: "inherit", + env, + } + ); + + if (result.error) { + throw result.error; + } + + process.exitCode = result.status; +} else { + console.error( + "The pglt CLI package doesn't ship with prebuilt binaries for your platform yet. Please file an issue in the main repository." + ); + process.exitCode = 1; +} From 5bf5a70266dfb04a4f31949a44cb5e828905c0d3 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 15:17:46 +0100 Subject: [PATCH 32/41] desc --- packages/@pglt/pglt/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index d14e0ba2..c36600b5 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -21,7 +21,7 @@ } ], "license": "MIT or Apache-2.0", - "description": "", + "description": "A collection of language tools and a Language Server Protocol (LSP) implementation for Postgres, focusing on developer experience and reliable SQL tooling.", "files": [ "bin/pglt", "schema.json" From 9d190c783237f7d8eecdb423f1e7beb344059bcd Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 15:57:51 +0100 Subject: [PATCH 33/41] prepwork --- .github/workflows/publish.dispatch.yml | 36 ++++++++++++++++++- .github/workflows/publish.reusable.yml | 5 ++- .github/workflows/publish.trigger.yml | 13 +++++++ .../@pglt/pglt/scripts/generate-packages.mjs | 8 +++-- 4 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/publish.trigger.yml diff --git a/.github/workflows/publish.dispatch.yml b/.github/workflows/publish.dispatch.yml index d07a80cd..d608910e 100644 --- a/.github/workflows/publish.dispatch.yml +++ b/.github/workflows/publish.dispatch.yml @@ -1,4 +1,4 @@ -name: Publish NPM (Dispatch) +name: Publish NPM (Manual) on: workflow_dispatch: @@ -9,7 +9,41 @@ on: description: Release Tag to Publish jobs: + validate_tag: + uses: actions/github-script@v7 + with: + script: | + const tag = ''; + + let exhausted = false; + let page = 1; + while (!exhausted) { + const releases = octokit.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + page, + per_page: 100, + }); + + const matchingRelease = releases.find(r => r.tag_name === tag); + if (matchingRelease) { + core.setOutput('hasRelease', true); + core.setOutput('isPrerelease', release.prerelease); + return; + } + + if (releases.length < 100) { + exhausted = true; + } else { + page++ + } + } + + core.setOutput('hasRelease', false); + core.setOutput('isPrerelease', false); + publish_npm: + needs: validate_tag uses: ./.github/workflows/publish.reusable.yml with: release-tag: ${{ github.event.inputs.release_tag }} diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index a898ab44..87bcd2fc 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -30,10 +30,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_TAG: "0.1.0" + PRERELEASE: "true" - - name: DEBUG - run: cat packages/\@pglt/pglt/package.json - + # TODO: use latest/nightly tag depending on prerelease # - name: Publish npm packages as latest # run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done # env: diff --git a/.github/workflows/publish.trigger.yml b/.github/workflows/publish.trigger.yml new file mode 100644 index 00000000..9f162e7b --- /dev/null +++ b/.github/workflows/publish.trigger.yml @@ -0,0 +1,13 @@ +name: Publish NPM (Automatic) + +on: + release: + types: [released, prereleased] + +jobs: + publish_npm: + uses: ./.github/workflows/publish.reusable.yml + with: + release-tag: ${{ github.event.release.tag_name }} + is-prerelease: ${{ github.event.release.prerelease }} + secrets: inherit diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index a44bc96a..b7cccc46 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -176,11 +176,15 @@ function getOs(platform) { (async function main() { const githubToken = process.env.GITHUB_TOKEN; - const releaseTag = process.env.RELEASE_TAG; - + let releaseTag = process.env.RELEASE_TAG; assert(githubToken, "GITHUB_TOKEN not defined!"); assert(releaseTag, "RELEASE_TAG not defined!"); + const isPrerelease = process.env.PRERELEASE === "true"; + if (isPrerelease) { + releaseTag += "-rc"; + } + await downloadSchema(releaseTag, githubToken); overwriteManifestVersions(releaseTag); From 82cf431c23cf4c0ea71579e94c1e510a0ae675c3 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:34:26 +0100 Subject: [PATCH 34/41] improve left & right --- .github/workflows/publish.dispatch.yml | 86 ++++++++++++++++---------- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/.github/workflows/publish.dispatch.yml b/.github/workflows/publish.dispatch.yml index d608910e..7e196900 100644 --- a/.github/workflows/publish.dispatch.yml +++ b/.github/workflows/publish.dispatch.yml @@ -10,41 +10,59 @@ on: jobs: validate_tag: - uses: actions/github-script@v7 - with: - script: | - const tag = ''; - - let exhausted = false; - let page = 1; - while (!exhausted) { - const releases = octokit.rest.repos.listReleases({ - owner: context.repo.owner, - repo: context.repo.repo, - page, - per_page: 100, - }); - - const matchingRelease = releases.find(r => r.tag_name === tag); - if (matchingRelease) { - core.setOutput('hasRelease', true); - core.setOutput('isPrerelease', release.prerelease); - return; - } + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + id: validate-release + with: + script: | + const tag = core.getInput('release_tag', { required: true }); + + let exhausted = false; + let page = 1; + while (!exhausted) { + const releases = octokit.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + page, + per_page: 100, + }); + + const matchingRelease = releases.find(r => r.tag_name === tag); + if (matchingRelease) { + core.setOutput('hasRelease', true); + core.setOutput('isPrerelease', release.prerelease); + return; + } - if (releases.length < 100) { - exhausted = true; - } else { - page++ + if (releases.length < 100) { + exhausted = true; + } else { + page++ + } + } + + core.setOutput('hasRelease', false); + core.setOutput('isPrerelease', false); + + - name: Abort + if: ${{ !steps.validate-release.outputs.hasRelease }} + run: | + { + echo "Tag ${{ github.event.inputs.release_tag }} not found." + exit 1 } - } - core.setOutput('hasRelease', false); - core.setOutput('isPrerelease', false); + - name: Print Output + run: | + { + echo "Has Release: ${{ steps.validate-release.outputs.hasRelease }}" + echo "Is Prerelease: ${{ steps.validate-release.outputs.isPrerelease }}" + } - publish_npm: - needs: validate_tag - uses: ./.github/workflows/publish.reusable.yml - with: - release-tag: ${{ github.event.inputs.release_tag }} - secrets: inherit + # publish_npm: + # needs: validate_tag + # uses: ./.github/workflows/publish.reusable.yml + # with: + # release-tag: ${{ github.event.inputs.release_tag }} + # secrets: inherit From ee914d7cd1587d34f0df15bdbd118865322a5a51 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:35:35 +0100 Subject: [PATCH 35/41] test-release name --- packages/@pglt/pglt/scripts/generate-packages.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index b7cccc46..416ccab2 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -167,7 +167,7 @@ function getBuildName(platform, arch) { function getPackageName(platform, arch) { // trim the "unknown" from linux and the "pc" from windows const name = platform.split("-").slice(-2).join("-"); - return `@pglt/cli-${arch}-${name}`; + return `@pglt/testrelease-cli-${arch}-${name}`; } function getOs(platform) { From 72499a5de6832d42614a1c71b14c8c267df38f1d Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:36:27 +0100 Subject: [PATCH 36/41] ? --- packages/@pglt/pglt/bin/pglt | 12 ++++++------ packages/@pglt/pglt/package.json | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/@pglt/pglt/bin/pglt b/packages/@pglt/pglt/bin/pglt index 06101104..0dd9f286 100644 --- a/packages/@pglt/pglt/bin/pglt +++ b/packages/@pglt/pglt/bin/pglt @@ -7,16 +7,16 @@ const { platform, arch, env } = process; */ const PLATFORMS = { win32: { - x64: "@pglt/cli-x86_64-windows-msvc/pglt.exe", - arm64: "@pglt/cli-aarch64-windows-msvc/pglt.exe", + x64: "@pglt/testrelease-cli-x86_64-windows-msvc/pglt.exe", + arm64: "@pglt/testrelease-cli-aarch64-windows-msvc/pglt.exe", }, darwin: { - x64: "@pglt/cli-x86_64-apple-darwin/pglt", - arm64: "@pglt/cli-aarch64-apple-darwin/pglt", + x64: "@pglt/testrelease-cli-x86_64-apple-darwin/pglt", + arm64: "@pglt/testrelease-cli-aarch64-apple-darwin/pglt", }, linux: { - x64: "@pglt/cli-x86_64-linux-gnu/pglt", - arm64: "@pglt/cli-aarch64-linux-gnu/pglt", + x64: "@pglt/testrelease-cli-x86_64-linux-gnu/pglt", + arm64: "@pglt/testrelease-cli-aarch64-linux-gnu/pglt", }, }; diff --git a/packages/@pglt/pglt/package.json b/packages/@pglt/pglt/package.json index c36600b5..1f3a41ab 100644 --- a/packages/@pglt/pglt/package.json +++ b/packages/@pglt/pglt/package.json @@ -30,11 +30,11 @@ "node": ">=20" }, "optionalDependencies": { - "@pglt/cli-aarch64-apple-darwin": "", - "@pglt/cli-aarch64-windows-msvc": "", - "@pglt/cli-aarch64-linux-gnu": "", - "@pglt/cli-x86_64-apple-darwin": "", - "@pglt/cli-x86_64-windows-msvc": "", - "@pglt/cli-x86_64-linux-gnu": "" + "@pglt/testrelease-cli-aarch64-apple-darwin": "", + "@pglt/testrelease-cli-aarch64-windows-msvc": "", + "@pglt/testrelease-cli-aarch64-linux-gnu": "", + "@pglt/testrelease-cli-x86_64-apple-darwin": "", + "@pglt/testrelease-cli-x86_64-windows-msvc": "", + "@pglt/testrelease-cli-x86_64-linux-gnu": "" } } From 06615745d77081fd107c406f3fad9731a2becd57 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:43:11 +0100 Subject: [PATCH 37/41] ok --- .github/workflows/publish.reusable.yml | 27 ++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 87bcd2fc..0973c999 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -6,6 +6,9 @@ on: - main - supabase-community:main +env: + PRERELEASE: "true" + jobs: publish: name: Publish All the Things @@ -30,10 +33,22 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_TAG: "0.1.0" - PRERELEASE: "true" + PRERELEASE: ${{ env.PRERELEASE }} - # TODO: use latest/nightly tag depending on prerelease - # - name: Publish npm packages as latest - # run: for package in packages/@biomejs/*; do if [ $package != "packages/@biomejs/js-api" ]; then npm publish $package --tag latest --access public --provenance; fi; done - # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # TODO: use latest/nightly tag depending on prerelease + - name: Publish npm packages as nightly + if: env.PRELEASE == 'true' + run: | + for package in packages/@pglt/*; do + npm publish $package --tag nightly --access public --provenance + done + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # + - name: Publish npm packages as latest + if: env.PRELEASE != 'true' + run: | + for package in packages/@pglt/*; do + npm publish $package --tag latest --access public --provenance + done + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # From ea97ad833af3f29ff3a075937347d28375551c59 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:46:54 +0100 Subject: [PATCH 38/41] ack --- .../@pglt/pglt/scripts/generate-packages.mjs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/@pglt/pglt/scripts/generate-packages.mjs b/packages/@pglt/pglt/scripts/generate-packages.mjs index 416ccab2..2d1b89af 100644 --- a/packages/@pglt/pglt/scripts/generate-packages.mjs +++ b/packages/@pglt/pglt/scripts/generate-packages.mjs @@ -64,12 +64,14 @@ async function downloadBinary(platform, arch, os, releaseTag, githubToken) { console.log(`Downloaded asset for ${buildName} (v${releaseTag})`); } -async function overwriteManifestVersions(releaseTag) { +async function overwriteManifestVersions(releaseTag, isPrerelease) { + const version = getVersion(releaseTag, isPrerelease); + const manifestClone = structuredClone(rootManifest); - manifestClone.version = releaseTag; + manifestClone.version = version; for (const key in manifestClone.optionalDependencies) { - manifestClone.optionalDependencies[key] = releaseTag; + manifestClone.optionalDependencies[key] = version; } fs.writeFileSync(MANIFEST_PATH, JSON.stringify(manifestClone, null, 2)); @@ -174,6 +176,10 @@ function getOs(platform) { return platform.split("-").find((_, idx) => idx === 1); } +function getVersion(releaseTag, isPrerelease) { + return releaseTag + (isPrerelease ? "-rc" : ""); +} + (async function main() { const githubToken = process.env.GITHUB_TOKEN; let releaseTag = process.env.RELEASE_TAG; @@ -181,12 +187,9 @@ function getOs(platform) { assert(releaseTag, "RELEASE_TAG not defined!"); const isPrerelease = process.env.PRERELEASE === "true"; - if (isPrerelease) { - releaseTag += "-rc"; - } await downloadSchema(releaseTag, githubToken); - overwriteManifestVersions(releaseTag); + overwriteManifestVersions(releaseTag, isPrerelease); for (const platform of SUPPORTED_PLATFORMS) { const os = getOs(platform); From 78be9bf9057429b967f90a6f198d32873621536c Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:49:46 +0100 Subject: [PATCH 39/41] another --- .github/workflows/publish.reusable.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 0973c999..a1d90e60 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -6,9 +6,6 @@ on: - main - supabase-community:main -env: - PRERELEASE: "true" - jobs: publish: name: Publish All the Things @@ -35,9 +32,8 @@ jobs: RELEASE_TAG: "0.1.0" PRERELEASE: ${{ env.PRERELEASE }} - # TODO: use latest/nightly tag depending on prerelease - name: Publish npm packages as nightly - if: env.PRELEASE == 'true' + if: false run: | for package in packages/@pglt/*; do npm publish $package --tag nightly --access public --provenance @@ -45,7 +41,7 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # - name: Publish npm packages as latest - if: env.PRELEASE != 'true' + if: true run: | for package in packages/@pglt/*; do npm publish $package --tag latest --access public --provenance From d920fc9856e76790574b3ce0a8254380c4614c7d Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:52:47 +0100 Subject: [PATCH 40/41] verify --- .github/workflows/publish.reusable.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index a1d90e60..51f885de 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -32,6 +32,13 @@ jobs: RELEASE_TAG: "0.1.0" PRERELEASE: ${{ env.PRERELEASE }} + - name: Verify NPM TOKEN exists + if: !!secrets.NPM_TOKEN + run: | + { + echo "Found NPM Token" + } + - name: Publish npm packages as nightly if: false run: | @@ -40,6 +47,7 @@ jobs: done env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # + - name: Publish npm packages as latest if: true run: | @@ -47,4 +55,4 @@ jobs: npm publish $package --tag latest --access public --provenance done env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 099350c7aa597f902602a23a2ff480f01712fc76 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 21 Feb 2025 18:55:57 +0100 Subject: [PATCH 41/41] ok --- .github/workflows/publish.reusable.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.reusable.yml b/.github/workflows/publish.reusable.yml index 51f885de..64c2d3a0 100644 --- a/.github/workflows/publish.reusable.yml +++ b/.github/workflows/publish.reusable.yml @@ -33,11 +33,13 @@ jobs: PRERELEASE: ${{ env.PRERELEASE }} - name: Verify NPM TOKEN exists - if: !!secrets.NPM_TOKEN run: | - { - echo "Found NPM Token" - } + if [ -z "${{ secrets.NPM_TOKEN }}" ]; then + echo "Secret is not defined" + exit 1 + else + echo "Secret is defined" + fi - name: Publish npm packages as nightly if: false