Skip to content

[wip] chore: add publish npm action #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
064b3f2
chore: add publish npm action
juleswritescode Feb 21, 2025
a9f36e7
don't have that yet
juleswritescode Feb 21, 2025
3e24df4
copy that schema
juleswritescode Feb 21, 2025
4afd792
add thangs
juleswritescode Feb 21, 2025
125f8fc
ok?
juleswritescode Feb 21, 2025
6baf503
trim names
juleswritescode Feb 21, 2025
6b0aa3d
debug thing
juleswritescode Feb 21, 2025
eaf3097
ok?
juleswritescode Feb 21, 2025
0ce8fa3
changy change
juleswritescode Feb 21, 2025
f63de17
like so?
juleswritescode Feb 21, 2025
d7cf708
make it test
juleswritescode Feb 21, 2025
dbe1924
well
juleswritescode Feb 21, 2025
9e3e092
thats not a valid alias
juleswritescode Feb 21, 2025
711fb48
use pipes
juleswritescode Feb 21, 2025
f4abd92
rework
juleswritescode Feb 21, 2025
38e30cf
ocd
juleswritescode Feb 21, 2025
584c67a
wrong platform name
juleswritescode Feb 21, 2025
ebd6760
debug
juleswritescode Feb 21, 2025
c698b4c
well...
juleswritescode Feb 21, 2025
10d0822
more sexy
juleswritescode Feb 21, 2025
92c9658
thats not an underscore
juleswritescode Feb 21, 2025
348dfaf
schema src
juleswritescode Feb 21, 2025
d436948
escape?
juleswritescode Feb 21, 2025
a1607c5
cleanup
juleswritescode Feb 21, 2025
c3b03b2
herantasten
juleswritescode Feb 21, 2025
bbde5f7
these underscores dang
juleswritescode Feb 21, 2025
29e9dbd
it apparently works
juleswritescode Feb 21, 2025
9250363
restructure
juleswritescode Feb 21, 2025
7a4f004
ls that stuff
juleswritescode Feb 21, 2025
59bd643
cat instead
juleswritescode Feb 21, 2025
7aed7f4
this the script?
juleswritescode Feb 21, 2025
5bf5a70
desc
juleswritescode Feb 21, 2025
9d190c7
prepwork
juleswritescode Feb 21, 2025
82cf431
improve left & right
juleswritescode Feb 21, 2025
ee914d7
test-release name
juleswritescode Feb 21, 2025
72499a5
?
juleswritescode Feb 21, 2025
0661574
ok
juleswritescode Feb 21, 2025
ea97ad8
ack
juleswritescode Feb 21, 2025
78be9bf
another
juleswritescode Feb 21, 2025
d920fc9
verify
juleswritescode Feb 21, 2025
099350c
ok
juleswritescode Feb 21, 2025
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
68 changes: 68 additions & 0 deletions .github/workflows/publish.dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish NPM (Manual)

on:
workflow_dispatch:
inputs:
release_tag:
type: string
required: true
description: Release Tag to Publish

jobs:
validate_tag:
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++
}
}

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
}

- 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
60 changes: 60 additions & 0 deletions .github/workflows/publish.reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish to NPM & Brew

on:
pull_request:
branches:
- main
- supabase-community:main

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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: "0.1.0"
PRERELEASE: ${{ env.PRERELEASE }}

- name: Verify NPM TOKEN exists
run: |
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
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: true
run: |
for package in packages/@pglt/*; do
npm publish $package --tag latest --access public --provenance
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/publish.trigger.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
46 changes: 46 additions & 0 deletions packages/@pglt/pglt/bin/pglt
Original file line number Diff line number Diff line change
@@ -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/testrelease-cli-x86_64-windows-msvc/pglt.exe",
arm64: "@pglt/testrelease-cli-aarch64-windows-msvc/pglt.exe",
},
darwin: {
x64: "@pglt/testrelease-cli-x86_64-apple-darwin/pglt",
arm64: "@pglt/testrelease-cli-aarch64-apple-darwin/pglt",
},
linux: {
x64: "@pglt/testrelease-cli-x86_64-linux-gnu/pglt",
arm64: "@pglt/testrelease-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;
}
40 changes: 40 additions & 0 deletions packages/@pglt/pglt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "pglt",
"version": "<placeholder>",
"bin": {
"pglt": "bin/pglt"
},
"repository": {
"type": "git",
"url": "git+https://github.com/supabase/postgres_lsp.git",
"directory": "packages/@pglt/pglt"
},
"author": "Supabase Community",
"contributors": [
{
"name": "Philipp Steinrötter",
"url": "https://github.com/psteinroe"
},
{
"name": "Julian Domke",
"url": "https://github.com/juleswritescode"
}
],
"license": "MIT or Apache-2.0",
"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"
],
"engines": {
"node": ">=20"
},
"optionalDependencies": {
"@pglt/testrelease-cli-aarch64-apple-darwin": "<placeholder>",
"@pglt/testrelease-cli-aarch64-windows-msvc": "<placeholder>",
"@pglt/testrelease-cli-aarch64-linux-gnu": "<placeholder>",
"@pglt/testrelease-cli-x86_64-apple-darwin": "<placeholder>",
"@pglt/testrelease-cli-x86_64-windows-msvc": "<placeholder>",
"@pglt/testrelease-cli-x86_64-linux-gnu": "<placeholder>"
}
}
Loading
Loading