Skip to content

Commit cfa95b1

Browse files
committed
Publish standard library for jsoo
1 parent dd5a04f commit cfa95b1

File tree

7 files changed

+70
-21
lines changed

7 files changed

+70
-21
lines changed

.github/workflows/publish.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
- 5.0.x
1717
node-version:
1818
- 14.x
19+
ocaml-compiler:
20+
- 4.12.x
1921

2022
runs-on: ${{ matrix.os }}
2123

@@ -34,15 +36,36 @@ jobs:
3436
with:
3537
node-version: ${{ matrix.node-version }}
3638

39+
- name: Use OCaml ${{ matrix.ocaml-compiler }}
40+
uses: ocaml/setup-ocaml@v2
41+
with:
42+
ocaml-compiler: ${{ matrix.ocaml-compiler }}
43+
dune-cache: true
44+
3745
- name: Install .NET Dependencies
3846
run: dotnet restore
3947
| dotnet tool restore
4048

49+
- name: Install OCaml Dependencies
50+
run: opam install js_of_ocaml-compiler js_of_ocaml-ppx ojs
51+
4152
- name: Run FAKE
42-
run: dotnet fake build target Build
53+
run: dotnet fake build target All
54+
55+
- name: Push js_of_ocaml standard library to jsoo-stdlib
56+
if: success()
57+
uses: s0/git-publish-subdir-action@develop
58+
env:
59+
REPO: self
60+
BRANCH: jsoo-stdlib
61+
FOLDER: dist_jsoo
62+
TAG: ${{ github.ref }}
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
MESSAGE: "Build {sha}:\n{msg}"
4365

4466
- name: NPM Publish
67+
if: success()
4568
uses: JS-DevTools/npm-publish@v1
4669
with:
4770
token: ${{ secrets.NPM_TOKEN }}
48-
check-version: true
71+
check-version: true

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.0.2] - 2021-11-02
10+
Testing if package is published correctly when we create an release on GitHub.
11+
Also created an OPAM package for js_of_ocaml.
12+
13+
## [0.0.1] - 2021-10-22
14+
Test publishing to npm.
15+
916
## [0.0.0] - 2021-10-21
1017
In development.

build.fsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ open Fake.IO.Globbing.Operators
2121
open Fake.IO.FileSystemOperators
2222
open Fake.JavaScript
2323

24+
let rootDir = Path.getFullName "."
2425
let srcDir = "./src"
2526
let outputDir = "./output"
2627
let distDir = "./dist"
2728
let testDir = "./test"
2829

30+
let inDirectory dirName action =
31+
Shell.cd dirName
32+
action ()
33+
Shell.cd rootDir
34+
2935
let run cmd dir args =
3036
let result =
3137
CreateProcess.fromRawCommandLine cmd args
@@ -131,8 +137,7 @@ module Test =
131137
let build () =
132138
for file in outputDir |> Shell.copyRecursiveTo true srcDir do
133139
printfn "* copied to %s" file
134-
Shell.cd testDir
135-
dune "build"
140+
inDirectory testDir <| fun () -> dune "build"
136141

137142
Target.create "TestJsooGenerateBindings" <| fun _ -> Test.Jsoo.generateBindings ()
138143
Target.create "TestJsooBuild" <| fun _ -> Test.Jsoo.build ()
@@ -170,30 +175,33 @@ module Deploy =
170175
let copyArtifacts () =
171176
let mliDir = outputDir </> "test_jsoo"
172177
let mlDir = testDir </> "jsoo/_build/default/src"
173-
let targets = ["ts2ocaml_es"; "ts2ocaml_dom"; "ts2ocaml_webworker"]
178+
let targets = ["ts2ocaml_min"; "ts2ocaml_es"; "ts2ocaml_dom"; "ts2ocaml_webworker"]
174179
let targetDir = targetDir </> "src"
175180
for target in targets do
181+
Shell.rm (targetDir </> $"{target}.mli")
176182
Shell.copyFile targetDir (mliDir </> $"{target}.mli")
183+
Shell.rm (targetDir </> $"{target}.ml")
177184
Shell.copyFile targetDir (mlDir </> $"{target}.ml")
178185

179186
let versionRegex =
180187
String.getRegEx "\\(version ((?>\\w\\.)*\\w)\\)"
181188

182189
let updateVersion () =
183-
File.read duneProject
184-
|> Seq.map (fun line ->
185-
let result = versionRegex.Match line
190+
duneProject |> File.applyReplace (fun content ->
191+
let result = versionRegex.Match content
186192
if result.Success then
187193
let oldVersion = result.Groups.[1].Value
188194
if oldVersion <> newVersion then
189195
printfn $"* updating version in dist_jsoo/dune-project from '{oldVersion}' to '{newVersion}'."
190-
"(version ${newVersion})"
196+
content |> String.replace result.Value $"(version {newVersion})"
191197
else
192198
printfn $"* version in dist_jsoo/dune-project not updated ('{newVersion}')."
193-
line
194-
else
195-
line)
196-
|> File.write false duneProject
199+
content
200+
else content
201+
)
202+
203+
let testBuild () =
204+
inDirectory targetDir <| fun () -> dune "build"
197205

198206
Target.create "Deploy" <| fun _ -> ()
199207
Target.create "DeployOnly" <| fun _ -> ()
@@ -204,14 +212,24 @@ Target.create "DeployNpm" <| fun _ ->
204212
Target.create "DeployJsoo" <| fun _ ->
205213
Deploy.Jsoo.copyArtifacts ()
206214
Deploy.Jsoo.updateVersion ()
215+
Deploy.Jsoo.testBuild ()
207216

208217
"BuildOnly"
209218
==> "DeployNpm"
210219
==> "DeployJsoo"
211220
==> "DeployOnly"
212221
==> "Deploy"
213222

223+
"TestJsoo" ==> "DeployJsoo"
224+
214225
"Build" ==> "Deploy"
215226

227+
Target.create "All" ignore
228+
229+
"Build"
230+
==> "Test"
231+
==> "Deploy"
232+
==> "All"
233+
216234
// start build
217235
Target.runOrDefault "Build"

dist_jsoo/dune-project

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(lang dune 2.7)
2-
(name ts2ocaml-stdlib)
3-
(version 0.0.0)
2+
(name ts2ocaml-jsoo-stdlib)
3+
(version 0.0.2)
44

55
(maintainers "[email protected]")
66
(authors
@@ -13,8 +13,8 @@
1313
(license Apache-2.0)
1414

1515
(package
16-
(name ts2ocaml-stdlib)
17-
(synopsis "Standard Library for ts2ocaml generated bindings")
16+
(name ts2ocaml-jsoo-stdlib)
17+
(synopsis "Standard library for ts2ocaml generated bindings (js_of_ocaml target)")
1818
(description "You can choose not to use this standard library. See the documents in the repository.")
1919
(depends
2020
(ocaml (>= 4.08))

dist_jsoo/src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(library
22
(name ts2ocaml)
3-
(public_name ts2ocaml-stdlib)
3+
(public_name ts2ocaml-jsoo-stdlib)
44
(libraries ojs)
55
(wrapped false)
66
(modes byte)

dist_jsoo/ts2ocaml-stdlib.opam renamed to dist_jsoo/ts2ocaml-jsoo-stdlib.opam

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# This file is generated by dune, edit dune-project instead
22
opam-version: "2.0"
3-
version: "0.0.0"
4-
synopsis: "Standard Library for ts2ocaml generated bindings"
3+
version: "0.0.2"
4+
synopsis:
5+
"Standard library for ts2ocaml generated bindings (js_of_ocaml target)"
56
description:
67
"You can choose not to use this standard library. See the documents in the repository."
78
maintainer: ["[email protected]"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ocsigen/ts2ocaml",
3-
"version": "0.0.1-1",
3+
"version": "0.0.2",
44
"description": "Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)