From c25bae6594a52b17bb32b856579c9cbdec5a0fa3 Mon Sep 17 00:00:00 2001 From: Valery Petrov Date: Sun, 8 Nov 2026 17:34:55 -0800 Subject: [PATCH] Tag the built core library on git as core-v npm cannot install a package from a folder of a git repository, and dist is not committed. A workflow now packs packages/core after CI passes on main and pushes the packed files as the tag core-v, so that npm install git+https://...#core-v works without npm. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/core-git.yml | 70 ++++++++++++++++++++++++++++++++++ packages/core/README.md | 7 +--- 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/core-git.yml diff --git a/.github/workflows/core-git.yml b/.github/workflows/core-git.yml new file mode 100644 index 0000000..c3b54a0 --- /dev/null +++ b/.github/workflows/core-git.yml @@ -0,0 +1,70 @@ +name: Core on git + +# Tags the built core library as core-v, so that npm can install it from git. +on: + workflow_run: + workflows: [CI] + types: [completed] + branches: [main] + workflow_dispatch: + inputs: + ref: + description: Tag or commit to build + default: main + +permissions: + contents: write + +concurrency: + group: core-git + cancel-in-progress: false + +defaults: + run: + shell: bash + +jobs: + core: + if: github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.ref || github.event.workflow_run.head_sha }} + - uses: actions/setup-node@v6 + with: + node-version: 24 + cache: npm + - name: Find the version and whether it is tagged + id: version + run: | + version=$(node -p "require('./packages/core/package.json').version") + echo "tag=core-v$version" >> "$GITHUB_OUTPUT" + if git ls-remote --exit-code origin "refs/tags/core-v$version" > /dev/null; then + echo "tagged=true" >> "$GITHUB_OUTPUT" + echo "::notice::core-v$version is already tagged." + else + echo "tagged=false" >> "$GITHUB_OUTPUT" + fi + - if: steps.version.outputs.tagged == 'false' + run: npm ci + - if: steps.version.outputs.tagged == 'false' + run: npm run build -w packages/core + - if: steps.version.outputs.tagged == 'false' + run: npm test -w packages/core + - name: Tag the packed library + if: steps.version.outputs.tagged == 'false' + env: + TAG: ${{ steps.version.outputs.tag }} + run: | + source=$(git rev-parse HEAD) + npm pack -w packages/core --pack-destination "$RUNNER_TEMP" + mkdir "$RUNNER_TEMP/core" + tar -xzf "$RUNNER_TEMP"/clickhouse-sql-syntax-*.tgz -C "$RUNNER_TEMP/core" --strip-components=1 + cd "$RUNNER_TEMP/core" + git init -q + git add -A + git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ + commit -qm "clickhouse-sql-syntax ${TAG#core-v}, built from $source" + git push "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" "HEAD:refs/tags/$TAG" diff --git a/packages/core/README.md b/packages/core/README.md index 31552bf..40cb61d 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -5,13 +5,10 @@ in TypeScript with no runtime dependencies. ## Install -It is not on npm yet. Build it from the [repository](https://github.com/valerypetrov/clickhouse-sql-syntax) (Node.js 22 or newer) -and install the folder in your project: +It is not on npm. Each version is on git as the tag `core-v`, built and ready to install: ```sh -git clone https://github.com/valerypetrov/clickhouse-sql-syntax.git -cd clickhouse-sql-syntax && npm install && npm run build -w packages/core -cd ../your-project && npm install ../clickhouse-sql-syntax/packages/core +npm install git+https://github.com/valerypetrov/clickhouse-sql-syntax.git#core-v0.5.0 ``` ## API