mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-06-06 07:41:41 +00:00
6df2d0049b
Also make sure the library soname is set on linux and macos Signed-off-by: Lee Smet <lee.smet@hotmail.com>
236 lines
8.0 KiB
YAML
236 lines
8.0 KiB
YAML
name: Release
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- v[0-9]+.*
|
|
|
|
jobs:
|
|
create-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: taiki-e/create-gh-release-action@v1
|
|
with:
|
|
changelog: CHANGELOG.md
|
|
# (required) GitHub token for creating GitHub Releases.
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
upload-assets-mycelium:
|
|
needs: create-release
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: taiki-e/upload-rust-binary-action@v1
|
|
with:
|
|
# Name of the compiled binary, also name of the non-extension part of the produced file
|
|
bin: mycelium
|
|
# --target flag value, default is host
|
|
target: ${{ matrix.target }}
|
|
# Name of the archive when uploaded
|
|
archive: $bin-$target
|
|
# (required) GitHub token for uploading assets to GitHub Releases.
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
# Specify manifest since we are in a subdirectory
|
|
manifest-path: myceliumd/Cargo.toml
|
|
|
|
# TODO: Figure out the correct matrix setup to have this in a single action
|
|
upload-assets-myceliumd-private:
|
|
needs: create-release
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: taiki-e/upload-rust-binary-action@v1
|
|
with:
|
|
# Name of the compiled binary, also name of the non-extension part of the produced file
|
|
bin: mycelium-private
|
|
# Set the vendored-openssl flag for provided release builds
|
|
features: vendored-openssl
|
|
# --target flag value, default is host
|
|
target: ${{ matrix.target }}
|
|
# Name of the archive when uploaded
|
|
archive: $bin-$target
|
|
# (required) GitHub token for uploading assets to GitHub Releases.
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
# Specify manifest since we are in a subdirectory
|
|
manifest-path: myceliumd-private/Cargo.toml
|
|
|
|
upload-assets-libmycelium:
|
|
needs: create-release
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: aarch64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
dyn_lib: libmycelium.so
|
|
dyn_versioned: libmycelium.so.0
|
|
link_arg: -Wl,-soname,libmycelium.so.0
|
|
cross_apt: gcc-aarch64-linux-gnu
|
|
cross_linker_var: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER
|
|
cross_linker_val: aarch64-linux-gnu-gcc
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
dyn_lib: libmycelium.so
|
|
dyn_versioned: libmycelium.so.0
|
|
link_arg: -Wl,-soname,libmycelium.so.0
|
|
cross_apt: ""
|
|
cross_linker_var: ""
|
|
cross_linker_val: ""
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
dyn_lib: libmycelium.dylib
|
|
dyn_versioned: libmycelium.0.dylib
|
|
link_arg: -Wl,-install_name,@rpath/libmycelium.0.dylib
|
|
cross_apt: ""
|
|
cross_linker_var: ""
|
|
cross_linker_val: ""
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
dyn_lib: libmycelium.dylib
|
|
dyn_versioned: libmycelium.0.dylib
|
|
link_arg: -Wl,-install_name,@rpath/libmycelium.0.dylib
|
|
cross_apt: ""
|
|
cross_linker_var: ""
|
|
cross_linker_val: ""
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Install Linux cross toolchain
|
|
if: matrix.cross_apt != ''
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y ${{ matrix.cross_apt }}
|
|
|
|
- name: Build libmycelium
|
|
shell: bash
|
|
env:
|
|
RUSTFLAGS: -C link-arg=${{ matrix.link_arg }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -n "${{ matrix.cross_linker_var }}" ]; then
|
|
export ${{ matrix.cross_linker_var }}=${{ matrix.cross_linker_val }}
|
|
fi
|
|
cargo build --release \
|
|
--manifest-path mycelium/Cargo.toml \
|
|
--target ${{ matrix.target }} \
|
|
--features ffi
|
|
|
|
- name: Stage artifacts
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
TARGET_DIR="target/${{ matrix.target }}/release"
|
|
mkdir -p pkg/lib pkg/include
|
|
cp "$TARGET_DIR/${{ matrix.dyn_lib }}" "pkg/lib/${{ matrix.dyn_versioned }}"
|
|
ln -s "${{ matrix.dyn_versioned }}" "pkg/lib/${{ matrix.dyn_lib }}"
|
|
cp "$TARGET_DIR/libmycelium.a" pkg/lib/libmycelium.a
|
|
# cbindgen writes mycelium.h into the build-script OUT_DIR
|
|
# (target/<TARGET>/release/build/mycelium-<fingerprint>/out/).
|
|
# The dir name shares a prefix with sibling workspace crates
|
|
# (mycelium-tun, mycelium-api, ...) so glob on the file name —
|
|
# only mycelium/build.rs emits a header by that name.
|
|
mapfile -t headers < <(find "$TARGET_DIR/build" -type f -name mycelium.h)
|
|
if [ ${#headers[@]} -ne 1 ]; then
|
|
echo "Expected exactly one mycelium.h, found ${#headers[@]}:" >&2
|
|
printf ' %s\n' "${headers[@]}" >&2
|
|
exit 1
|
|
fi
|
|
cp "${headers[0]}" pkg/include/mycelium.h
|
|
|
|
- name: Verify SONAME / install_name
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${{ runner.os }}" = "Linux" ]; then
|
|
readelf -d "pkg/lib/${{ matrix.dyn_versioned }}" \
|
|
| grep -q 'SONAME.*libmycelium\.so\.0'
|
|
else
|
|
otool -D "pkg/lib/${{ matrix.dyn_versioned }}" \
|
|
| grep -q '@rpath/libmycelium\.0\.dylib'
|
|
fi
|
|
|
|
- name: Create tarball
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
VERSION="${GITHUB_REF_NAME#v}"
|
|
tar -czf "libmycelium-${VERSION}-${{ matrix.target }}.tar.gz" -C pkg .
|
|
|
|
- name: Upload tarball to release
|
|
uses: alexellis/upload-assets@0.4.0
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
with:
|
|
asset_paths: '["libmycelium-*.tar.gz"]'
|
|
|
|
build-msi:
|
|
needs: create-release
|
|
runs-on: windows-latest
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create .exe file
|
|
shell: bash
|
|
run: cd myceliumd && RUSTFLAGS="-C target-feature=+crt-static" cargo build --release && cd ..
|
|
|
|
- name: Setup .NET Core SDK
|
|
uses: actions/setup-dotnet@v4.0.0
|
|
|
|
- name: Install WiX Toolset
|
|
run: dotnet tool install --global wix --version 6.0.2
|
|
|
|
- name: Add WixToolset.UI.wixext extension
|
|
run: wix extension add WixToolset.UI.wixext/6.0.2
|
|
|
|
- name: Download Wintun zip file
|
|
run: curl -o wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
|
|
|
|
- name: Unzip Wintun
|
|
run: unzip wintun.zip
|
|
|
|
- name: Move .dll file to myceliumd directory
|
|
run: move wintun\bin\amd64\wintun.dll myceliumd
|
|
|
|
- name: Build MSI package
|
|
run: wix build -loc installers\windows\wix\mycelium.en-us.wxl installers\windows\wix\mycelium.wxs -ext WixToolset.UI.wixext -arch x64 -dcl high -out mycelium_installer.msi
|
|
|
|
- name: Upload MSI artifact
|
|
uses: alexellis/upload-assets@0.4.0
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
with:
|
|
asset_paths: '["mycelium_installer.msi"]'
|