From e864e88f07988077f2c1c53dd7c414cbc9a06b52 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Wed, 18 Sep 2024 19:00:25 +0200 Subject: [PATCH] Start preparing jsr publication of client lib --- .github/workflows/deno-ci.yaml | 23 ++++++++++++++++++++--- .github/workflows/jsr-publish-lib.yaml | 25 +++++++++++++++++++++++++ lib/common.ts | 16 +++++++++------- lib/{client.ts => deps.ts} | 9 ++++++++- lib/deps_jsr.ts | 0 with-jsr-deps.sh | 14 ++++++++++++++ 6 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/jsr-publish-lib.yaml rename lib/{client.ts => deps.ts} (50%) create mode 100644 lib/deps_jsr.ts create mode 100755 with-jsr-deps.sh diff --git a/.github/workflows/deno-ci.yaml b/.github/workflows/deno-ci.yaml index ff5b66a..122c3cf 100644 --- a/.github/workflows/deno-ci.yaml +++ b/.github/workflows/deno-ci.yaml @@ -13,9 +13,9 @@ jobs: strategy: matrix: deno-version: - - v1.28 - - v1.32 - - v1.36 + - v1.41 + - v1.43 + - v1.45 - canary fail-fast: false # run each branch to completion @@ -51,3 +51,20 @@ jobs: - name: Test run: time deno test + + audit-lib: + runs-on: ubuntu-latest + name: Audit ./lib + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Use Deno v1 + uses: denoland/setup-deno@v1 + with: + deno-version: v1 + + - name: Check publish rules + working-directory: lib + run: ../with-jsr-deps.sh deno publish --dry-run --allow-dirty diff --git a/.github/workflows/jsr-publish-lib.yaml b/.github/workflows/jsr-publish-lib.yaml new file mode 100644 index 0000000..2daf0cc --- /dev/null +++ b/.github/workflows/jsr-publish-lib.yaml @@ -0,0 +1,25 @@ +name: Publish +on: + push: + branches: + - main + paths: + - lib/jsr.json + +jobs: + publish: + runs-on: ubuntu-latest + name: Publish ./lib + + permissions: + contents: read + id-token: write + + steps: + - uses: denoland/setup-deno@v1 + + - uses: actions/checkout@v4 + + - name: Publish to JSR + working-directory: lib + run: ../with-jsr-deps.sh deno publish --allow-dirty diff --git a/lib/common.ts b/lib/common.ts index d62a639..e834247 100644 --- a/lib/common.ts +++ b/lib/common.ts @@ -2,17 +2,19 @@ // All the generated code uses this centralized API contract, // while users are free to pass in a different compatible client to actually call -import { toStatus } from './builtin/meta@v1/structs.ts'; import { ApiKind, - JSONObject, JSONValue, + JSONObject, + JSONValue, RequestOptions, -} from "https://deno.land/x/kubernetes_client@v0.7.0/lib/contract.ts"; - -export * from "https://deno.land/x/kubernetes_client@v0.7.0/lib/contract.ts"; + toStatus, +} from "./deps.ts"; export { - WatchEventTransformer -} from "https://deno.land/x/kubernetes_client@v0.7.0/lib/stream-transformers.ts"; + type RestClient, + type JSONValue, + type ApiKind, + WatchEventTransformer, +} from "./deps.ts"; // Helpers used to validate/transform structures from or for the wire // And some other stuff :) diff --git a/lib/client.ts b/lib/deps.ts similarity index 50% rename from lib/client.ts rename to lib/deps.ts index b14cd5d..e83d1a7 100644 --- a/lib/client.ts +++ b/lib/deps.ts @@ -1,6 +1,13 @@ // This file is just the entire matching kubernetes_client version. // kubernetes_apis itself only depends on specific files, -// so this is provided an optional utility (as opposed to deps.ts) +// so this is provided an optional utility export * from "https://deno.land/x/kubernetes_client@v0.7.0/mod.ts"; export * as tunnelBeta from "https://deno.land/x/kubernetes_client@v0.7.0/tunnel-beta/via-websocket.ts"; + +export { toStatus } from './builtin/meta@v1/structs.ts'; + +export * from "https://deno.land/x/kubernetes_client@v0.7.0/lib/contract.ts"; +export { + WatchEventTransformer +} from "https://deno.land/x/kubernetes_client@v0.7.0/lib/stream-transformers.ts"; diff --git a/lib/deps_jsr.ts b/lib/deps_jsr.ts new file mode 100644 index 0000000..e69de29 diff --git a/with-jsr-deps.sh b/with-jsr-deps.sh new file mode 100755 index 0000000..ee2ec6a --- /dev/null +++ b/with-jsr-deps.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh +set -ux + +mv deps.ts deps_https.ts +mv deps_jsr.ts deps.ts +undo () { + ARG=$? + mv deps.ts deps_jsr.ts + mv deps_https.ts deps.ts + exit $ARG +} +trap undo EXIT + +"$@"