Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Workflows

## release.yml — Build and Release

Builds C# bindings and publishes a GitHub Release with NuGet package.

- **Trigger**: automatically via `repository_dispatch` from `rgb-lib`, or manually
- **Input**: `rgb_lib_version` (e.g. `v0.3.0-beta.15`)
- **What it does**:
1. Downloads the native C-FFI library from `rgb-lib` release for each platform
2. Builds the .NET project per platform (Linux x64, macOS ARM64, Windows x64)
3. Combines all native libraries into a single multi-platform NuGet package
4. Creates a GitHub Release with the tag and `.nupkg`

## test.yml — Test Library (local)

Tests the C# bindings using **local** (checked out) code.

- **Trigger**: push to `main`, PRs to `main`, after release workflow, or manually
- **What it does**:
1. Downloads native C-FFI library from latest `rgb-lib` release
2. Builds the .NET project
3. Runs `tests/RgbLib.Tests` against the local project reference
4. Tests on Ubuntu, macOS, and Windows

## test_tag.yml — Test Library (published tag)

Tests the **published** NuGet package — simulates what end users do.

- **Trigger**: push of a `v*` tag (i.e. right after a release)
- **What it does**:
1. Downloads native C-FFI library from latest `rgb-lib` release
2. Replaces local project reference with the published NuGet package version
3. Runs `tests/RgbLib.Tests` against the published package
4. Tests on Ubuntu, macOS, and Windows
100 changes: 100 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Test Library

on:
repository_dispatch:
types: [rgb-lib-release]

workflow_run:
workflows: ["Build and Release"]
types:
- completed

workflow_dispatch:
inputs:
bitcoin_network:
description: 'Bitcoin network (signet, testnet, regtest)'
required: false
default: 'signet'
type: string

push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'

pull_request:
branches:
- main

jobs:
test:
name: Test (${{ matrix.rid }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
rid: linux-x64
lib_name: librgblibcffi.so
target: x86_64-unknown-linux-gnu
- runner: macos-latest
rid: osx-arm64
lib_name: librgblibcffi.dylib
target: aarch64-apple-darwin
- runner: windows-latest
rid: win-x64
lib_name: rgblibcffi.dll
target: x86_64-pc-windows-msvc

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Get latest rgb-lib version
id: rgb_lib_version
run: |
VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/UTEXO-Protocol/rgb-lib/releases | jq -r '.[0].tag_name')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Using rgb-lib version: $VERSION"
shell: bash

- name: Download rgb-lib C-FFI library
run: |
DOWNLOAD_URL="https://github.com/UTEXO-Protocol/rgb-lib/releases/download/${{ steps.rgb_lib_version.outputs.version }}/rgb-lib-cffi-${{ matrix.target }}.zip"
echo "Downloading from: $DOWNLOAD_URL"
curl -L -o cffi.zip "$DOWNLOAD_URL"
unzip -o cffi.zip
mkdir -p src/RgbLib/runtimes/${{ matrix.rid }}/native
cp ${{ matrix.lib_name }} src/RgbLib/runtimes/${{ matrix.rid }}/native/
ls -la src/RgbLib/runtimes/${{ matrix.rid }}/native/
shell: bash

- name: Build
run: |
cd src/RgbLib
dotnet build -c Release
shell: bash

- name: Run tests
env:
BITCOIN_NETWORK: ${{ inputs.bitcoin_network || 'signet' }}
MNEMONIC: ${{ secrets.TEST_MNEMONIC }}
ACCOUNT_XPUB_VANILLA: ${{ secrets.TEST_ACCOUNT_XPUB_VANILLA }}
ACCOUNT_XPUB_COLORED: ${{ secrets.TEST_ACCOUNT_XPUB_COLORED }}
MASTER_FINGERPRINT: ${{ secrets.TEST_MASTER_FINGERPRINT }}
INDEXER_URL: ${{ secrets.TEST_INDEXER_URL }}
LD_LIBRARY_PATH: ${{ github.workspace }}/src/RgbLib/runtimes/${{ matrix.rid }}/native
DYLD_LIBRARY_PATH: ${{ github.workspace }}/src/RgbLib/runtimes/${{ matrix.rid }}/native
run: |
cd tests/RgbLib.Tests
dotnet test -c Release --logger "console;verbosity=detailed"
shell: bash
88 changes: 88 additions & 0 deletions .github/workflows/test_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Test Library (tag)

on:
push:
tags:
- 'v*'

jobs:
test:
name: Test tag (${{ matrix.rid }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
rid: linux-x64
lib_name: librgblibcffi.so
target: x86_64-unknown-linux-gnu
- runner: macos-latest
rid: osx-arm64
lib_name: librgblibcffi.dylib
target: aarch64-apple-darwin
- runner: windows-latest
rid: win-x64
lib_name: rgblibcffi.dll
target: x86_64-pc-windows-msvc

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Get latest rgb-lib version
id: rgb_lib_version
run: |
VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/UTEXO-Protocol/rgb-lib/releases | jq -r '.[0].tag_name')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Using rgb-lib version: $VERSION"
shell: bash

- name: Download rgb-lib C-FFI library
run: |
DOWNLOAD_URL="https://github.com/UTEXO-Protocol/rgb-lib/releases/download/${{ steps.rgb_lib_version.outputs.version }}/rgb-lib-cffi-${{ matrix.target }}.zip"
echo "Downloading from: $DOWNLOAD_URL"
curl -L -o cffi.zip "$DOWNLOAD_URL"
unzip -o cffi.zip
mkdir -p src/RgbLib/runtimes/${{ matrix.rid }}/native
cp ${{ matrix.lib_name }} src/RgbLib/runtimes/${{ matrix.rid }}/native/
ls -la src/RgbLib/runtimes/${{ matrix.rid }}/native/
shell: bash

- name: Build library
run: |
cd src/RgbLib
dotnet build -c Release
shell: bash

- name: Install published NuGet package in test project
run: |
# Remove local project reference from test project, use NuGet package instead
NUGET_VERSION="${{ github.ref_name }}"
NUGET_VERSION="${NUGET_VERSION#v}"
cd tests/RgbLib.Tests
dotnet remove reference ../../src/RgbLib/RgbLib.csproj || true
dotnet add package RgbLib --version $NUGET_VERSION --source https://api.nuget.org/v3/index.json
dotnet restore
shell: bash

- name: Run tests
env:
BITCOIN_NETWORK: signet
MNEMONIC: ${{ secrets.TEST_MNEMONIC }}
ACCOUNT_XPUB_VANILLA: ${{ secrets.TEST_ACCOUNT_XPUB_VANILLA }}
ACCOUNT_XPUB_COLORED: ${{ secrets.TEST_ACCOUNT_XPUB_COLORED }}
MASTER_FINGERPRINT: ${{ secrets.TEST_MASTER_FINGERPRINT }}
INDEXER_URL: ${{ secrets.TEST_INDEXER_URL }}
LD_LIBRARY_PATH: ${{ github.workspace }}/src/RgbLib/runtimes/${{ matrix.rid }}/native
DYLD_LIBRARY_PATH: ${{ github.workspace }}/src/RgbLib/runtimes/${{ matrix.rid }}/native
run: |
cd tests/RgbLib.Tests
dotnet test -c Release --logger "console;verbosity=detailed"
shell: bash
Loading