Skip to content

Commit

Permalink
Integrate npm package publish
Browse files Browse the repository at this point in the history
Use the new workflows for Conan v2 to build and publish
and npm package

Contribute to NP-637
  • Loading branch information
jellespijker committed Dec 10, 2024
1 parent 9e99759 commit 0c3209f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: conan-package
name: package

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- '.github/workflows/conan-package.yml'
- '.github/workflows/package.yml'
branches:
- main
- 'CURA-*'
Expand All @@ -29,7 +29,7 @@ on:
- 'conanfile.py'
- 'conandata.yml'
- 'CMakeLists.txt'
- '.github/workflows/conan-package.yml'
- '.github/workflows/package.yml'
branches:
- main
- 'CURA-*'
Expand All @@ -40,7 +40,15 @@ on:

jobs:
conan-package:
uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main
uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@NP-637_conan_v2_wasm
with:
platform_wasm: true
secrets: inherit

npm-package:
needs: [ conan-package ]
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || contains(github.ref_name, 'NP-') || github.ref_name == '5.10') }} # FIXME: have a more generic way to determine release branches
uses: ultimaker/cura-workflows/.github/workflows/npm-package.yml@NP-637_conan_v2_wasm
with:
package_version_full: ${{ needs.conan-package.outputs.package_version_full }}
secrets: inherit
3 changes: 0 additions & 3 deletions CuraEngineJS/.npmrc

This file was deleted.

13 changes: 0 additions & 13 deletions CuraEngineJS/package-lock.json

This file was deleted.

38 changes: 0 additions & 38 deletions CuraEngineJS/package.json

This file was deleted.

35 changes: 28 additions & 7 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import copy, mkdir, update_conandata
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.files import copy, mkdir, update_conandata
from conan.tools.scm import Version, Git

required_conan_version = ">=2.7.0"
Expand Down Expand Up @@ -61,8 +60,10 @@ def export_sources(self):
copy(self, "CuraEngine.rc", self.recipe_folder, self.export_sources_folder)
copy(self, "LICENSE", self.recipe_folder, self.export_sources_folder)
copy(self, "*", os.path.join(self.recipe_folder, "src"), os.path.join(self.export_sources_folder, "src"))
copy(self, "*", os.path.join(self.recipe_folder, "include"), os.path.join(self.export_sources_folder, "include"))
copy(self, "*", os.path.join(self.recipe_folder, "benchmark"), os.path.join(self.export_sources_folder, "benchmark"))
copy(self, "*", os.path.join(self.recipe_folder, "include"),
os.path.join(self.export_sources_folder, "include"))
copy(self, "*", os.path.join(self.recipe_folder, "benchmark"),
os.path.join(self.export_sources_folder, "benchmark"))
copy(self, "*", os.path.join(self.recipe_folder, "stress_benchmark"),
os.path.join(self.export_sources_folder, "stress_benchmark"))
copy(self, "*", os.path.join(self.recipe_folder, "tests"), os.path.join(self.export_sources_folder, "tests"))
Expand Down Expand Up @@ -136,7 +137,8 @@ def generate(self):
tc.variables["ENABLE_TESTING"] = not self.conf.get("tools.build:skip_test", False, check_type=bool)
tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14"
tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(
self.settings.compiler.version) < "14"
tc.variables["ENABLE_THREADING"] = not (self.settings.arch == "wasm" and self.settings.os == "Emscripten")
if self.options.enable_plugins:
tc.variables["ENABLE_PLUGINS"] = True
Expand Down Expand Up @@ -180,7 +182,7 @@ def build(self):
cmake.configure()
cmake.build()

self.send_sentry_debug_files(binary_basename = "CuraEngine")
self.send_sentry_debug_files(binary_basename="CuraEngine")

def deploy(self):
copy(self, "CuraEngine*", src=os.path.join(self.package_folder, "bin"), dst=self.deploy_folder)
Expand All @@ -202,3 +204,22 @@ def package_info(self):
ext = ".exe" if self.settings.os == "Windows" else ""
self.conf_info.define_path("user.curaengine:curaengine",
os.path.join(self.package_folder, "bin", f"CuraEngine{ext}"))
if self.settings.os == "Emscripten":
package_json = {
"name": f"@ultimaker/{self.name.lower()}js",
"version": f"{str(self.version).replace('+', '-')}", # npm will otherwise 'sanitize' the version number
"description": f"JavaScript / TypeScript bindings for {self.name}, a {self.description}",
"main": "bin/CuraEngine.js",
"repository": {
"type": "git",
"url": self.url
},
"author": self.author,
"license": self.license,
"keywords": self.topics,
"files": [
"bin",
"package.json"
]
}
self.conf_info.define(f"user.{self.name.lower()}:package_json", package_json)

0 comments on commit 0c3209f

Please sign in to comment.