From cbe7710a87c68c9c3d9fe5e95269f8bcb4d5bfd9 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Mon, 7 Oct 2024 13:40:59 +1100 Subject: [PATCH] publish step --- .gitlab-ci.yml | 28 ++++++++++++++++++---------- npm/darwin-x64/README.md | 3 --- npm/darwin-x64/package.json | 18 ------------------ npm/linux-x64-gnu/package.json | 2 +- npm/win32-x64-msvc/package.json | 2 +- src/lib.rs | 7 ++++--- 6 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 npm/darwin-x64/README.md delete mode 100644 npm/darwin-x64/package.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7bffc23..3164749 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,14 +2,18 @@ stages: - build - publish -build: - stage: build - image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/rust:1.81.0-bookworm +.parallel-config: parallel: matrix: - TARGET: - x86_64-unknown-linux-gnu - x86_64-pc-windows-msvc + +build: + stage: build + image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/rust:1.81.0-bookworm + extends: + - .parallel-config script: - rustup target add $TARGET - rustup toolchain install stable-$TARGET @@ -24,10 +28,14 @@ build: - index.d.ts - droplet.*.node -# publish: -# stage: publish -# image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node:21 -# script: -# - echo "@drop:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc -# - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc -# - yarn publish \ No newline at end of file +publish: + stage: publish + dependencies: + - build + image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node:21 + script: + - echo "@drop:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc + - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc + - yarn + - yarn artifacts + - ls -R ./npm \ No newline at end of file diff --git a/npm/darwin-x64/README.md b/npm/darwin-x64/README.md deleted file mode 100644 index 7471abe..0000000 --- a/npm/darwin-x64/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `droplet-darwin-x64` - -This is the **x86_64-apple-darwin** binary for `droplet` diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json deleted file mode 100644 index 0db02cf..0000000 --- a/npm/darwin-x64/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "droplet-darwin-x64", - "version": "0.0.0", - "os": [ - "darwin" - ], - "cpu": [ - "x64" - ], - "main": "droplet.darwin-x64.node", - "files": [ - "droplet.darwin-x64.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index 6c14740..1a31518 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,5 +1,5 @@ { - "name": "droplet-linux-x64-gnu", + "name": "@drop/droplet-linux-x64-gnu", "version": "0.0.0", "os": [ "linux" diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index 9701e1b..1c9c3ed 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,5 +1,5 @@ { - "name": "droplet-win32-x64-msvc", + "name": "@drop/droplet-win32-x64-msvc", "version": "0.0.0", "os": [ "win32" diff --git a/src/lib.rs b/src/lib.rs index a550487..9a1da03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ use napi::Error; use std::{ collections::HashMap, fs::File, - io::{BufRead, BufReader}, + io::{self, BufRead, BufReader}, path::Path, sync::{Arc, Mutex}, }; @@ -23,11 +23,12 @@ pub mod manifest; #[macro_use] extern crate napi_derive; -fn compress(buffer: &[u8], output_path: &Path, chunk_id: Uuid) { +fn compress(mut buffer: &[u8], output_path: &Path, chunk_id: Uuid) { let chunk_path = output_path.join(chunk_id.to_string() + ".bin"); let chunk_file = File::create_new(chunk_path).unwrap(); + let mut compressor = zstd::Encoder::new(chunk_file, 5).unwrap(); - zstd::stream::copy_encode(buffer, chunk_file, 9).unwrap(); + io::copy(&mut buffer, &mut compressor).unwrap(); } #[napi]