mirror of
https://github.com/logos-storage/logos-storage-go-bindings.git
synced 2026-03-30 16:03:13 +00:00
Merge pull request #26 from logos-storage/chore/bump-to-0-0-32
chore: bump logos storage nim to 0.3.2
This commit is contained in:
commit
2e34d40f39
146
.github/workflows/artifacts.yml
vendored
146
.github/workflows/artifacts.yml
vendored
@ -1,146 +0,0 @@
|
||||
name: Artifacts
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.target.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
target:
|
||||
- os: ubuntu-latest
|
||||
cpu: amd64
|
||||
lib_ext: so
|
||||
|
||||
- os: ubuntu-24.04-arm
|
||||
cpu: arm64
|
||||
lib_ext: so
|
||||
|
||||
- os: macos-latest
|
||||
lib_ext: dylib
|
||||
cpu: arm64
|
||||
|
||||
- os: windows-latest
|
||||
cpu: amd64
|
||||
lib_ext: dll
|
||||
|
||||
steps:
|
||||
- name: Enable long paths (Windows)
|
||||
if: matrix.target.os == 'windows-latest'
|
||||
shell: powershell
|
||||
run: |
|
||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
|
||||
git config --system core.longpaths true
|
||||
|
||||
- name: Check out sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Install Rust 1.85.0
|
||||
if: matrix.target.os != 'windows-latest'
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
|
||||
- name: Record submodule commit
|
||||
run: git -C vendor/logos-storage-nim rev-parse HEAD > vendor/logos-storage-nim/.storage-commit
|
||||
|
||||
- name: Cache libstorage build
|
||||
id: cache-libstorage
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: vendor/logos-storage-nim/build
|
||||
key: ${{ runner.os }}-${{ matrix.target.cpu }}-libstorage-${{ hashFiles('vendor/logos-storage-nim/.storage-commit') }}
|
||||
|
||||
- name: MSYS2 (Windows amd64)
|
||||
if: matrix.target.os == 'windows-latest' && matrix.target.cpu == 'amd64'
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
path-type: inherit
|
||||
msystem: UCRT64
|
||||
install: >-
|
||||
base-devel
|
||||
git
|
||||
mingw-w64-ucrt-x86_64-toolchain
|
||||
mingw-w64-ucrt-x86_64-cmake
|
||||
mingw-w64-ucrt-x86_64-ntldd-git
|
||||
mingw-w64-ucrt-x86_64-rust
|
||||
|
||||
- name: Build libstorage (Linux)
|
||||
if: matrix.target.lib_ext == 'so' && steps.cache-libstorage.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
make update
|
||||
make libstorage
|
||||
|
||||
- name: Build libstorage (MacOS)
|
||||
if: matrix.target.os == 'macos-latest' && steps.cache-libstorage.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
make update
|
||||
STORAGE_LIB_PARAMS="--passL:\"-Wl,-install_name,@rpath/libstorage.dylib\"" make libstorage
|
||||
|
||||
- name: Build libstorage (Windows)
|
||||
if: matrix.target.os == 'windows-latest' && steps.cache-libstorage.outputs.cache-hit != 'true'
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
pacman -Sy --noconfirm make
|
||||
git config --global core.symlinks false
|
||||
make update
|
||||
make libstorage
|
||||
|
||||
- name: Package artifacts Linux
|
||||
if: matrix.target.os == 'ubuntu-latest' || matrix.target.os == 'ubuntu-24.04-arm'
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y zip
|
||||
ZIPFILE=storage-linux-${{ matrix.target.cpu }}.zip
|
||||
zip -j $ZIPFILE vendor/logos-storage-nim/build/libstorage.${{ matrix.target.lib_ext }} vendor/logos-storage-nim/library/libstorage.h
|
||||
echo "ZIPFILE=$ZIPFILE" >> $GITHUB_ENV
|
||||
|
||||
- name: Package artifacts MacOS
|
||||
if: matrix.target.os == 'macos-latest'
|
||||
run: |
|
||||
ZIPFILE=storage-macos-${{ matrix.target.cpu }}.zip
|
||||
zip -j $ZIPFILE vendor/logos-storage-nim/build/libstorage.${{ matrix.target.lib_ext }} vendor/logos-storage-nim/library/libstorage.h
|
||||
echo "ZIPFILE=$ZIPFILE" >> $GITHUB_ENV
|
||||
|
||||
- name: Package artifacts (Windows)
|
||||
if: matrix.target.os == 'windows-latest'
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
ZIPFILE=storage-windows-${{ matrix.target.cpu }}.zip
|
||||
(cd vendor/logos-storage-nim/build && 7z a -tzip "${GITHUB_WORKSPACE}/${ZIPFILE}" libstorage.dll)
|
||||
(cd vendor/logos-storage-nim/library && 7z a -tzip "${GITHUB_WORKSPACE}/${ZIPFILE}" libstorage.h)
|
||||
echo "ZIPFILE=$ZIPFILE" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.ZIPFILE }}
|
||||
path: ${{ env.ZIPFILE }}
|
||||
if-no-files-found: error
|
||||
|
||||
publish-release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- name: Check out sources
|
||||
uses: actions/checkout@v4
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
path: dist
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: dist/**
|
||||
draft: true
|
||||
14
README.md
14
README.md
@ -22,8 +22,8 @@ CGO_LDFLAGS := -L$(LIBS_DIR) -lstorage -Wl,-rpath,$(LIBS_DIR)
|
||||
# Fetch configuration
|
||||
OS ?= "linux"
|
||||
ARCH ?= "amd64"
|
||||
VERSION ?= "v0.0.21"
|
||||
DOWNLOAD_URL := "https://github.com/logos-storage/logos-storage-go-bindings/releases/download/$(VERSION)/storage-${OS}-${ARCH}.zip"
|
||||
VERSION ?= "v0.3.2"
|
||||
DOWNLOAD_URL := "https://github.com/logos-storage/logos-storage-nim/releases/download/$(VERSION)/libstorage-${OS}-${ARCH}-$(VERSION).zip"
|
||||
|
||||
# Edit your binary name here
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@ -34,9 +34,9 @@ endif
|
||||
|
||||
fetch:
|
||||
@echo "Fetching libstorage from GitHub Actions from: ${DOWNLOAD_URL}"
|
||||
@curl -fSL --create-dirs -o $(LIBS_DIR)/storage-${OS}-${ARCH}.zip ${DOWNLOAD_URL}
|
||||
@unzip -o -qq $(LIBS_DIR)/storage-${OS}-${ARCH}.zip -d $(LIBS_DIR)
|
||||
@rm -f $(LIBS_DIR)/*.zip
|
||||
curl -fSL --create-dirs -o $(LIBS_DIR)/libstorage-${OS}-${ARCH}-$(VERSION).zip ${DOWNLOAD_URL}
|
||||
unzip -o -qq $(LIBS_DIR)/libstorage-${OS}-${ARCH}-$(VERSION).zip -d $(LIBS_DIR)
|
||||
rm -f $(LIBS_DIR)/*.zip
|
||||
|
||||
build:
|
||||
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BIN_NAME) main.go
|
||||
@ -49,7 +49,7 @@ clean:
|
||||
First you need to `fetch` the artefacts for your `OS` and `ARCH`:
|
||||
|
||||
```sh
|
||||
OS=macos ARCH=arm64 make fetch
|
||||
OS=darwin ARCH=arm64 make fetch
|
||||
```
|
||||
|
||||
Then you can build your project using:
|
||||
@ -60,7 +60,7 @@ make build
|
||||
|
||||
That's it!
|
||||
|
||||
For an example on how to use this package, please take a look at our [example-go-bindings](https://github.com/logos-storage/example-logos-storage-go-bindings) repo.
|
||||
For an example on how to use this package, please take a look at our [example-go-bindings](https://github.com/logos-storage/logos-storage-go-bindings-example) repo.
|
||||
|
||||
If you want to build the library yourself, you need to clone this repo and follow the instructions
|
||||
of the next step.
|
||||
|
||||
28
RELEASE.md
28
RELEASE.md
@ -23,7 +23,7 @@ git push --tags
|
||||
|
||||
Once published, the artifacts can be downloaded using the `version`, example:
|
||||
|
||||
`https://github.com/logos-storage/logos-storage-go-bindings/releases/download/v0.0.16/storage-linux-amd64.zip`
|
||||
`https://github.com/logos-storage/logos-storage-nim/releases/download/v0.3.2/libstorage-linux-amd64-v0.3.2.zip`
|
||||
|
||||
It is not recommended to use the `latest` URL because you may face cache issues.
|
||||
|
||||
@ -41,26 +41,26 @@ Then you can use the following `Makefile` command to fetch the artifact:
|
||||
LIBS_DIR := $(abspath ./libs)
|
||||
STORAGE_OS := linux
|
||||
STORAGE_ARCH := amd64
|
||||
STORAGE_VERSION := $(shell go list -m -f '{{.Version}}' github.com/logos-storage/logos-storage-go-bindings 2>/dev/null)
|
||||
STORAGE_DOWNLOAD_URL := "https://github.com/logos-storage/logos-storage-go-bindings/releases/download/$(STORAGE_VERSION)/storage-${STORAGE_OS}-${STORAGE_ARCH}.zip"
|
||||
STORAGE_VERSION := v0.3.2
|
||||
STORAGE_DOWNLOAD_URL := "https://github.com/logos-storage/logos-storage-nim/releases/download/$(STORAGE_VERSION)/libstorage-${STORAGE_OS}-${STORAGE_ARCH}-${STORAGE_VERSION}.zip"
|
||||
|
||||
fetch-libstorage:
|
||||
mkdir -p $(LIBS_DIR); \
|
||||
curl -fSL --create-dirs -o $(LIBS_DIR)/storage-${STORAGE_OS}-${STORAGE_ARCH}.zip ${STORAGE_DOWNLOAD_URL}; \
|
||||
unzip -o -qq $(LIBS_DIR)/storage-${STORAGE_OS}-${STORAGE_ARCH}.zip -d $(LIBS_DIR); \
|
||||
rm -f $(LIBS_DIR)/storage*.zip;
|
||||
curl -fSL --create-dirs -o $(LIBS_DIR)/libstorage-${STORAGE_OS}-${STORAGE_ARCH}-${STORAGE_VESION}.zip ${STORAGE_DOWNLOAD_URL}; \
|
||||
unzip -o -qq $(LIBS_DIR)/libstorage-${STORAGE_OS}-${STORAGE_ARCH}-${STORAGE_VESION}.zip -d $(LIBS_DIR); \
|
||||
rm -f $(LIBS_DIR)/libstorage*.zip;
|
||||
```
|
||||
|
||||
`STORAGE_VERSION` uses the same version as the Logos Storage Go dependency declared in your project.
|
||||
`STORAGE_VERSION` is the release version from Logos Storage Nim.
|
||||
|
||||
### Nix
|
||||
|
||||
If you use Nix in a sandboxed environment, you cannot use curl to download the artifacts, so you have to prefetch them using the artifacts `SHA-256` hash. To generate the hash, you can use the following command:
|
||||
|
||||
```bash
|
||||
nix store prefetch-file --json --unpack https://github.com/logos-storage/logos-storage-go-bindings/releases/download/v0.0.26/storage-macos-arm64.zip | jq -r .hash
|
||||
nix store prefetch-file --json --unpack https://github.com/logos-storage/logos-storage-nim/releases/download/v0.3.2/libstorage-darwin-arm64-v0.3.2.zip | jq -r .hash
|
||||
|
||||
# [10.4 MiB DL] sha256-3CHIWoSjo0plsYqzXQWm1EtY1STcljV4yfXTPon90uE=
|
||||
# sha256-YnMhmM0/JAmpdVref24n8l08UY7me0IQBbelIBfz2UE=
|
||||
```
|
||||
|
||||
Then include this hash in your Nix configuration. For example:
|
||||
@ -76,14 +76,14 @@ let
|
||||
os = if stdenv.isDarwin then "macos" else "Linux";
|
||||
hash =
|
||||
if stdenv.hostPlatform.isDarwin
|
||||
# nix store prefetch-file --json --unpack https://github.com/logos-storage/logos-storage-go-bindings/releases/download/v0.0.26/storage-macos-arm64.zip | jq -r .hash
|
||||
then "sha256-3CHIWoSjo0plsYqzXQWm1EtY1STcljV4yfXTPon90uE="
|
||||
# nix store prefetch-file --json --unpack https://github.com/logos-storage/logos-storage-go-bindings/releases/download/v0.0.26/storage-Linux-amd64.zip | jq -r .hash
|
||||
else "sha256-YxW2vFZlcLrOx1PYgWW4MIstH/oFBRF0ooS0sl3v6ig=";
|
||||
# nix store prefetch-file --json --unpack https://github.com/logos-storage/logos-storage-nim/releases/download/v0.3.2/libstorage-darwin-arm64-v0.3.2.zip | jq -r .hash
|
||||
then "sha256-YnMhmM0/JAmpdVref24n8l08UY7me0IQBbelIBfz2UE=="
|
||||
# nix store prefetch-file --json --unpack https://github.com/logos-storage/logos-storage-nim/releases/download/v0.3.2/libstorage-linux-amd64-v0.3.2.zip | jq -r .hash
|
||||
else "sha256-YDrT+MhXDMuKHwi1Dhg+uMg0vsC2PchlvX1Rb3HkRow=";
|
||||
|
||||
# Pre-fetch libstorage to avoid network during build
|
||||
storageLib = pkgs.fetchzip {
|
||||
url = "https://github.com/logos-storage/logos-storage-go-bindings/releases/download/${storageVersion}/storage-${os}-${arch}.zip";
|
||||
url = "https://github.com/logos-storage/logos-storage-nim/releases/download/${storageVersion}/libstorage-${os}-${arch}-${storageVersion}.zip";
|
||||
hash = hash;
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
@ -31,16 +31,16 @@ package storage
|
||||
return storage_close(storageCtx, (StorageCallback) callback, resp);
|
||||
}
|
||||
|
||||
static int cGoStorageDestroy(void* storageCtx, void* resp) {
|
||||
return storage_destroy(storageCtx, (StorageCallback) callback, resp);
|
||||
static int cGoStorageDestroy(void* storageCtx) {
|
||||
return storage_destroy(storageCtx);
|
||||
}
|
||||
|
||||
static int cGoStorageVersion(void* storageCtx, void* resp) {
|
||||
return storage_version(storageCtx, (StorageCallback) callback, resp);
|
||||
static char* cGoStorageVersion(void* storageCtx) {
|
||||
return storage_version(storageCtx);
|
||||
}
|
||||
|
||||
static int cGoStorageRevision(void* storageCtx, void* resp) {
|
||||
return storage_revision(storageCtx, (StorageCallback) callback, resp);
|
||||
static char* cGoStorageRevision(void* storageCtx) {
|
||||
return storage_revision(storageCtx);
|
||||
}
|
||||
|
||||
static int cGoStorageRepo(void* storageCtx, void* resp) {
|
||||
@ -276,7 +276,7 @@ func (node StorageNode) Destroy() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if C.cGoStorageDestroy(node.ctx, bridge.resp) != C.RET_OK {
|
||||
if C.cGoStorageDestroy(node.ctx) != C.RET_OK {
|
||||
return bridge.callError("cGoStorageDestroy")
|
||||
}
|
||||
|
||||
@ -289,26 +289,18 @@ func (node StorageNode) Destroy() error {
|
||||
}
|
||||
|
||||
// Version returns the version of the Logos Storage node.
|
||||
func (node StorageNode) Version() (string, error) {
|
||||
bridge := newBridgeCtx()
|
||||
defer bridge.free()
|
||||
func (node StorageNode) Version() string {
|
||||
cStr := C.cGoStorageVersion(node.ctx)
|
||||
defer C.free(unsafe.Pointer(cStr))
|
||||
|
||||
if C.cGoStorageVersion(node.ctx, bridge.resp) != C.RET_OK {
|
||||
return "", bridge.callError("cGoStorageVersion")
|
||||
}
|
||||
|
||||
return bridge.wait()
|
||||
return C.GoString(cStr)
|
||||
}
|
||||
|
||||
func (node StorageNode) Revision() (string, error) {
|
||||
bridge := newBridgeCtx()
|
||||
defer bridge.free()
|
||||
func (node StorageNode) Revision() string {
|
||||
cStr := C.cGoStorageRevision(node.ctx)
|
||||
defer C.free(unsafe.Pointer(cStr))
|
||||
|
||||
if C.cGoStorageRevision(node.ctx, bridge.resp) != C.RET_OK {
|
||||
return "", bridge.callError("cGoStorageRevision")
|
||||
}
|
||||
|
||||
return bridge.wait()
|
||||
return C.GoString(cStr)
|
||||
}
|
||||
|
||||
// Repo returns the path of the data dir folder.
|
||||
|
||||
@ -13,10 +13,8 @@ func TestStorageVersion(t *testing.T) {
|
||||
t.Fatalf("Failed to create Logos Storage node: %v", err)
|
||||
}
|
||||
|
||||
version, err := node.Version()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get Logos Storage version: %v", err)
|
||||
}
|
||||
version := node.Version()
|
||||
|
||||
if version == "" {
|
||||
t.Fatal("Logos Storage version is empty")
|
||||
}
|
||||
@ -31,10 +29,8 @@ func TestStorageRevision(t *testing.T) {
|
||||
t.Fatalf("Failed to create Logos Storage node: %v", err)
|
||||
}
|
||||
|
||||
revision, err := node.Revision()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get Logos Storage revision: %v", err)
|
||||
}
|
||||
revision := node.Revision()
|
||||
|
||||
if revision == "" {
|
||||
t.Fatal("Logos Storage revision is empty")
|
||||
}
|
||||
|
||||
2
vendor/logos-storage-nim
vendored
2
vendor/logos-storage-nim
vendored
@ -1 +1 @@
|
||||
Subproject commit 3c09f008bb5266a669fd19f18368f9e8b861b664
|
||||
Subproject commit 3bc6aa8b8d5ee72d23d793a0e909016214cdd599
|
||||
Loading…
x
Reference in New Issue
Block a user