From 299d9f59ced32cf3516fde0d02dfdbb2afb6e54a Mon Sep 17 00:00:00 2001 From: Torben Ewert Date: Fri, 22 May 2026 11:01:05 +0200 Subject: [PATCH] ci: publish pincfmt as npm package --- .github/workflows/publish-npm.yml | 102 ++++++++++++++++++++++++++++++ js/package-lock.json | 13 ++++ js/package.json | 18 ++++++ js/pincfmt.bc.d.ts | 1 + 4 files changed, 134 insertions(+) create mode 100644 .github/workflows/publish-npm.yml create mode 100644 js/package-lock.json create mode 100644 js/package.json create mode 100644 js/pincfmt.bc.d.ts diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..ac53284 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,102 @@ +name: Publish npm + +on: + push: + tags: + - '**' + + release: + types: + - created + + workflow_dispatch: + +jobs: + build: + name: Build and publish npm packages + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + ocaml-compiler: + - 5.4.x + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Use OCaml ${{ matrix.ocaml-compiler }} + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + opam-repositories: | + default: https://github.com/ocaml/opam-repository.git + archive: https://github.com/ocaml/opam-repository-archive.git + + - name: Get opam cache + id: cache-opam-dependencies + uses: actions/cache@v5 + with: + path: | + _opam/ + key: + ${{ matrix.os }}-${{ matrix.ocaml-compiler }}-opam-cache-dependencies-${{ hashFiles('**/*.opam', + '**/*.opam.locked') }} + + - name: Install opam dependencies + if: steps.cache-opam-dependencies.outputs.cache-hit != 'true' + run: opam install . --deps-only --yes + + - name: Save opam cache + if: always() && steps.cache-opam-dependencies.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: | + _opam/ + key: + ${{ matrix.os }}-${{ matrix.ocaml-compiler }}-opam-cache-dependencies-${{ hashFiles('**/*.opam', + '**/*.opam.locked') }} + + - name: Build Production Executables + run: opam exec -- dune build --profile=release + + - name: Upload JS build + uses: actions/upload-artifact@v7 + with: + name: js + path: js + + publish: + name: Publish to registry + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Install Node + uses: actions/setup-node@v6 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + package-manager-cache: false + + - name: Checkout + uses: actions/checkout@v6 + + - name: Download JS build + uses: actions/download-artifact@v8 + with: + name: js + path: js + + - name: Install NPM Dependencies + run: | + cd js + npm ci + + - name: Publish to Package Registry + run: | + cd js + npm publish diff --git a/js/package-lock.json b/js/package-lock.json new file mode 100644 index 0000000..58b8053 --- /dev/null +++ b/js/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "@pinc-official/pincfmt", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@pinc-official/pincfmt", + "version": "0.0.1", + "license": "MIT" + } + } +} diff --git a/js/package.json b/js/package.json new file mode 100644 index 0000000..f206252 --- /dev/null +++ b/js/package.json @@ -0,0 +1,18 @@ +{ + "name": "@pinc-official/pincfmt", + "version": "0.0.1", + "description": "Provides functions to format pinc-lang source code", + "homepage": "https://github.com/pinc-official/pinc-lang#readme", + "bugs": { + "url": "https://github.com/pinc-official/pinc-lang/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/pinc-official/pinc-lang.git" + }, + "license": "MIT", + "author": "Torben Ewert ", + "type": "commonjs", + "main": "./pincfmt.bc.js", + "types": "./pincfmt.bc.d.ts" +} diff --git a/js/pincfmt.bc.d.ts b/js/pincfmt.bc.d.ts new file mode 100644 index 0000000..3cadc68 --- /dev/null +++ b/js/pincfmt.bc.d.ts @@ -0,0 +1 @@ +export function pinc_format(source: string): string; -- 2.51.2