Skip to content

Commit

Permalink
Bump version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Mar 14, 2024
1 parent 294ed1d commit f54f419
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 7 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/install-cross.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

curl -s https://api.github.com/repos/cross-rs/cross/releases/latest \
| grep cross-x86_64-unknown-linux-gnu.tar.gz \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -

tar -zxvf cross-x86_64-unknown-linux-gnu.tar.gz -C /usr/bin
rm -f cross-x86_64-unknown-linux-gnu.tar.gz

85 changes: 85 additions & 0 deletions .github/workflows/publish-exe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
on:
push:
tags:
- "v*.*.*"

name: Publish Releases

jobs:
build_publish:
name: Publishing Tasks
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- i686-unknown-linux-musl
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc

include:
- target: x86_64-unknown-linux-gnu
host_os: ubuntu-latest
- target: x86_64-unknown-linux-musl
host_os: ubuntu-latest
- target: i686-unknown-linux-musl
host_os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
host_os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf
host_os: ubuntu-latest
- target: x86_64-apple-darwin
host_os: macos-latest
- target: aarch64-apple-darwin
host_os: macos-latest
- target: x86_64-pc-windows-msvc
host_os: windows-latest
- target: i686-pc-windows-msvc
host_os: windows-latest

runs-on: ${{ matrix.host_os }}
steps:
- uses: actions/checkout@v3

- name: Prepare
shell: bash
run: |
mkdir mypubdir4
rustup target add ${{ matrix.target }}
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
sudo .github/workflows/install-cross.sh
fi
- name: Build
shell: bash
run: |
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
cross build --all-features --release --target ${{ matrix.target }}
else
cargo build --all-features --release --target ${{ matrix.target }}
fi
cbindgen --config cbindgen.toml -l C -o target/dns2socks-ffi.h
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then
powershell -Command "(Get-Item README.md).LastWriteTime = Get-Date"
powershell Compress-Archive -Path target/${{ matrix.target }}/release/dns2socks.exe, README.md, target/dns2socks-ffi.h, target/${{ matrix.target }}/release/dns2socks.dll -DestinationPath mypubdir4/dns2socks-${{ matrix.target }}.zip
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks-ffi.h target/${{ matrix.target }}/release/libdns2socks.dylib
if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then
./build-apple.sh
zip -r mypubdir4/dns2socks-apple-xcframework.zip ./dns2socks.xcframework/
fi
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks-ffi.h target/${{ matrix.target }}/release/libdns2socks.so
fi
- name: Publish
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: mypubdir4/*

28 changes: 28 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Push or PR

on:
[push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
build_n_test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: rustfmt
run: |
rustc --version
cargo fmt --all -- --check
- name: check
run: cargo check --verbose
- name: clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose --tests --all-features
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dns2socks.xcframework/
Cargo.lock
.vscode/
.VSCodeCounter/
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dns2socks"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "MIT"
repository = "https://github.com/ssrlive/dns2socks"
Expand Down
45 changes: 45 additions & 0 deletions build-apple.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /bin/sh

echo "Setting up the rust environment..."
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios x86_64-apple-darwin aarch64-apple-darwin
cargo install cbindgen

echo "Building..."
cargo build --release --target x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
cargo build --release --target aarch64-apple-ios
cargo build --release --target x86_64-apple-ios
cargo build --release --target aarch64-apple-ios-sim

echo "Generating includes..."
mkdir -p target/include/
cbindgen --config cbindgen.toml -l C -o target/include/dns2socks.h
cat > target/include/module.modulemap <<EOF
framework module dns2socks {
umbrella header "dns2socks.h"
export *
module * { export * }
}
EOF

echo "lipo..."
echo "Simulator"
lipo -create \
target/aarch64-apple-ios-sim/release/libdns2socks.a \
target/x86_64-apple-ios/release/libdns2socks.a \
-output ./target/libdns2socks-ios-sim.a

echo "MacOS"
lipo -create \
target/aarch64-apple-darwin/release/libdns2socks.a \
target/x86_64-apple-darwin/release/libdns2socks.a \
-output ./target/libdns2socks-macos.a

echo "Creating XCFramework"
rm -rf ./dns2socks.xcframework
xcodebuild -create-xcframework \
-library ./target/aarch64-apple-ios/release/libdns2socks.a -headers ./target/include/ \
-library ./target/libdns2socks-ios-sim.a -headers ./target/include/ \
-library ./target/libdns2socks-macos.a -headers ./target/include/ \
-output ./dns2socks.xcframework
3 changes: 3 additions & 0 deletions cbindgen.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[export]
include = ["dns2socks_start", "dns2socks_stop", "dns2socks_set_log_callback"]
exclude = []
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use tokio::{
net::{TcpListener, TcpStream, ToSocketAddrs, UdpSocket},
};
use trust_dns_proto::op::{Message, Query};
pub use {
::tokio_util::sync::CancellationToken,
api::{dns2socks_start, dns2socks_stop},
config::{ArgVerbosity, Config},
dump_logger::dns2socks_set_log_callback,
};

pub use ::tokio_util::sync::CancellationToken;
pub use api::{dns2socks_start, dns2socks_stop};
pub use config::{ArgVerbosity, Config};
pub use dump_logger::dns2socks_set_log_callback;

const MAX_BUFFER_SIZE: usize = 4096;

Expand Down

0 comments on commit f54f419

Please sign in to comment.