-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable platform/arch specific packages
publish packages "@pact-foundation/pact-core-darwin-arm64": "16.0.0", "@pact-foundation/pact-core-darwin-x64": "16.0.0", "@pact-foundation/pact-core-linux-arm64-glibc": "16.0.0", "@pact-foundation/pact-core-linux-arm64-musl": "16.0.0", "@pact-foundation/pact-core-linux-x64-glibc": "16.0.0", "@pact-foundation/pact-core-linux-x64-musl": "16.0.0", "@pact-foundation/pact-core-windows-x64": "16.0.0"
- Loading branch information
Showing
13 changed files
with
318 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,6 @@ reports | |
tmp | ||
.tmp | ||
test/__testoutput__ | ||
|
||
# platform-arch specific packages | ||
@pact-foundation/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
SHELL:=/bin/bash | ||
export bin=@pact-foundation/pact-core | ||
export pkg_version?=$(shell cat package.json | jq -r .version) | ||
supported_platforms?="linux-x64-glibc" "linux-arm64-glibc" "linux-x64-musl" "linux-arm64-musl" "darwin-x64" "darwin-arm64" "windows-x64" | ||
|
||
# https://github.com/npm/npm/issues/17722 | ||
# https://github.com/npm/cli/issues/4828 | ||
# https://github.com/orhun/packaging-rust-for-npm | ||
# https://blog.orhun.dev/packaging-rust-for-npm/ | ||
|
||
clean: | ||
rm -rf @pact-foundation | ||
npm run clean-libs | ||
libs: | ||
FETCH_ASSETS=true ./script/ci/check-release-libs.sh --fetch-assets -t v$(pkg_version) | ||
|
||
DRY_RUN?=--dry-run | ||
build_opt_deps: | ||
for supported_platform in $(supported_platforms); do \ | ||
IFS='-' read -r node_os node_arch node_libc <<< "$$supported_platform"; \ | ||
export node_os=$$node_os; \ | ||
export node_arch=$$node_arch; \ | ||
export node_libc=$$node_libc; \ | ||
if [ "$$node_os" = "windows" ]; then \ | ||
export node_os="win32"; \ | ||
fi; \ | ||
if [ "$$node_libc" = "glibc" ]; then \ | ||
export libc='"libc": ["glibc"],'; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]; then \ | ||
export libc='"libc": ["musl"],'; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]||[ "$$node_libc" = "glibc" ]; then \ | ||
export standalone_package=prebuilds/$$node_os-$$node_arch; \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch-$$node_libc; \ | ||
else \ | ||
export standalone_package=prebuilds/$$node_os-$$node_arch; \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch; \ | ||
fi; \ | ||
echo "Building for $$node_os-$$node_arch"; \ | ||
echo "Building $$node_pkg"; \ | ||
mkdir -p "$$node_pkg/prebuilds"; \ | ||
cp -R "$$standalone_package" "$$node_pkg/prebuilds"; \ | ||
if [ "$$node_libc" = "glibc" ]; then \ | ||
find "$$node_pkg/prebuilds" -type f -name '*musl*' -exec rm -f {} +; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]; then \ | ||
find "$$node_pkg/prebuilds" -type f ! -name '*musl*' -exec rm -f {} +; \ | ||
fi; \ | ||
envsubst < package.json.tmpl > "$$node_pkg/package.json"; \ | ||
(cd $$node_pkg && npm publish --access public $(DRY_RUN);)\ | ||
done | ||
|
||
update_opt_deps: | ||
@for supported_platform in $(supported_platforms); do \ | ||
IFS='-' read -r node_os node_arch node_libc <<< "$$supported_platform"; \ | ||
if [ "$$node_libc" = "musl" ]||[ "$$node_libc" = "glibc" ]; then \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch-$$node_libc; \ | ||
else \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch; \ | ||
fi; \ | ||
jq '.optionalDependencies."'$$node_pkg'" = "$(pkg_version)"' package.json > package-new.json; \ | ||
mv package-new.json package.json; \ | ||
done | ||
|
||
publish_opt_package: | ||
set -eu; for supported_platform in $(supported_platforms); do \ | ||
IFS='-' read -r node_os node_arch node_libc <<< "$$supported_platform"; \ | ||
export node_os=$$node_os; \ | ||
export node_arch=$$node_arch; \ | ||
export node_libc=$$node_libc; \ | ||
if [ "$$node_os" = "windows" ]; then \ | ||
export node_os="win32"; \ | ||
fi; \ | ||
if [ "$$node_libc" = "glibc" ]; then \ | ||
export libc='"libc": ["glibc"],'; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]; then \ | ||
export libc='"libc": ["musl"],'; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]||[ "$$node_libc" = "glibc" ]; then \ | ||
export standalone_package=prebuilds/$$node_os-$$node_arch-$$node_libc; \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch-$$node_libc; \ | ||
else \ | ||
export standalone_package=prebuilds/$$node_os-$$node_arch; \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch; \ | ||
fi; \ | ||
echo "Building for $$node_os-$$node_arch"; \ | ||
echo "Building $$node_pkg for $$node_os-$$node_arch"; \ | ||
(cd $$node_pkg && npm publish --access public $(DRY_RUN);)\ | ||
done | ||
link: | ||
set -eu; for supported_platform in $(supported_platforms); do \ | ||
IFS='-' read -r node_os node_arch node_libc <<< "$$supported_platform"; \ | ||
export node_os=$$node_os; \ | ||
export node_arch=$$node_arch; \ | ||
export node_libc=$$node_libc; \ | ||
if [ "$$node_os" = "windows" ]; then \ | ||
export node_os="win32"; \ | ||
fi; \ | ||
if [ "$$node_libc" = "glibc" ]; then \ | ||
export libc='"libc": ["glibc"],'; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]; then \ | ||
export libc='"libc": ["musl"],'; \ | ||
fi; \ | ||
if [ "$$node_libc" = "musl" ]||[ "$$node_libc" = "glibc" ]; then \ | ||
export standalone_package=prebuilds/$$node_os-$$node_arch-$$node_libc; \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch-$$node_libc; \ | ||
else \ | ||
export standalone_package=prebuilds/$$node_os-$$node_arch; \ | ||
export node_pkg=$(bin)-$$node_os-$$node_arch; \ | ||
fi; \ | ||
(cd $$node_pkg && npm link || echo "cannot link for platform";);\ | ||
npm link $$node_pkg || echo "cannot link for platform";\ | ||
done |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.