Skip to content

Commit f54f419

Browse files
committed
Bump version 0.1.2
1 parent 294ed1d commit f54f419

File tree

8 files changed

+179
-7
lines changed

8 files changed

+179
-7
lines changed

.github/workflows/install-cross.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
curl -s https://api.github.com/repos/cross-rs/cross/releases/latest \
4+
| grep cross-x86_64-unknown-linux-gnu.tar.gz \
5+
| cut -d : -f 2,3 \
6+
| tr -d \" \
7+
| wget -qi -
8+
9+
tar -zxvf cross-x86_64-unknown-linux-gnu.tar.gz -C /usr/bin
10+
rm -f cross-x86_64-unknown-linux-gnu.tar.gz
11+

.github/workflows/publish-exe.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*.*.*"
5+
6+
name: Publish Releases
7+
8+
jobs:
9+
build_publish:
10+
name: Publishing Tasks
11+
strategy:
12+
matrix:
13+
target:
14+
- x86_64-unknown-linux-gnu
15+
- x86_64-unknown-linux-musl
16+
- i686-unknown-linux-musl
17+
- aarch64-unknown-linux-gnu
18+
- armv7-unknown-linux-gnueabihf
19+
- x86_64-apple-darwin
20+
- aarch64-apple-darwin
21+
- x86_64-pc-windows-msvc
22+
- i686-pc-windows-msvc
23+
24+
include:
25+
- target: x86_64-unknown-linux-gnu
26+
host_os: ubuntu-latest
27+
- target: x86_64-unknown-linux-musl
28+
host_os: ubuntu-latest
29+
- target: i686-unknown-linux-musl
30+
host_os: ubuntu-latest
31+
- target: aarch64-unknown-linux-gnu
32+
host_os: ubuntu-latest
33+
- target: armv7-unknown-linux-gnueabihf
34+
host_os: ubuntu-latest
35+
- target: x86_64-apple-darwin
36+
host_os: macos-latest
37+
- target: aarch64-apple-darwin
38+
host_os: macos-latest
39+
- target: x86_64-pc-windows-msvc
40+
host_os: windows-latest
41+
- target: i686-pc-windows-msvc
42+
host_os: windows-latest
43+
44+
runs-on: ${{ matrix.host_os }}
45+
steps:
46+
- uses: actions/checkout@v3
47+
48+
- name: Prepare
49+
shell: bash
50+
run: |
51+
mkdir mypubdir4
52+
rustup target add ${{ matrix.target }}
53+
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
54+
sudo .github/workflows/install-cross.sh
55+
fi
56+
57+
- name: Build
58+
shell: bash
59+
run: |
60+
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
61+
cross build --all-features --release --target ${{ matrix.target }}
62+
else
63+
cargo build --all-features --release --target ${{ matrix.target }}
64+
fi
65+
cbindgen --config cbindgen.toml -l C -o target/dns2socks-ffi.h
66+
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then
67+
powershell -Command "(Get-Item README.md).LastWriteTime = Get-Date"
68+
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
69+
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then
70+
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks-ffi.h target/${{ matrix.target }}/release/libdns2socks.dylib
71+
if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then
72+
./build-apple.sh
73+
zip -r mypubdir4/dns2socks-apple-xcframework.zip ./dns2socks.xcframework/
74+
fi
75+
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
76+
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks-ffi.h target/${{ matrix.target }}/release/libdns2socks.so
77+
fi
78+
79+
- name: Publish
80+
uses: softprops/action-gh-release@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
files: mypubdir4/*
85+

.github/workflows/rust.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Push or PR
2+
3+
on:
4+
[push, pull_request]
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
build_n_test:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
15+
runs-on: ${{ matrix.os }}
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: rustfmt
20+
run: |
21+
rustc --version
22+
cargo fmt --all -- --check
23+
- name: check
24+
run: cargo check --verbose
25+
- name: clippy
26+
run: cargo clippy --all-targets --all-features -- -D warnings
27+
- name: Build
28+
run: cargo build --verbose --tests --all-features

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
dns2socks.xcframework/
12
Cargo.lock
23
.vscode/
34
.VSCodeCounter/

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dns2socks"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
license = "MIT"
66
repository = "https://github.com/ssrlive/dns2socks"

build-apple.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! /bin/sh
2+
3+
echo "Setting up the rust environment..."
4+
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios x86_64-apple-darwin aarch64-apple-darwin
5+
cargo install cbindgen
6+
7+
echo "Building..."
8+
cargo build --release --target x86_64-apple-darwin
9+
cargo build --release --target aarch64-apple-darwin
10+
cargo build --release --target aarch64-apple-ios
11+
cargo build --release --target x86_64-apple-ios
12+
cargo build --release --target aarch64-apple-ios-sim
13+
14+
echo "Generating includes..."
15+
mkdir -p target/include/
16+
cbindgen --config cbindgen.toml -l C -o target/include/dns2socks.h
17+
cat > target/include/module.modulemap <<EOF
18+
framework module dns2socks {
19+
umbrella header "dns2socks.h"
20+
21+
export *
22+
module * { export * }
23+
}
24+
EOF
25+
26+
echo "lipo..."
27+
echo "Simulator"
28+
lipo -create \
29+
target/aarch64-apple-ios-sim/release/libdns2socks.a \
30+
target/x86_64-apple-ios/release/libdns2socks.a \
31+
-output ./target/libdns2socks-ios-sim.a
32+
33+
echo "MacOS"
34+
lipo -create \
35+
target/aarch64-apple-darwin/release/libdns2socks.a \
36+
target/x86_64-apple-darwin/release/libdns2socks.a \
37+
-output ./target/libdns2socks-macos.a
38+
39+
echo "Creating XCFramework"
40+
rm -rf ./dns2socks.xcframework
41+
xcodebuild -create-xcframework \
42+
-library ./target/aarch64-apple-ios/release/libdns2socks.a -headers ./target/include/ \
43+
-library ./target/libdns2socks-ios-sim.a -headers ./target/include/ \
44+
-library ./target/libdns2socks-macos.a -headers ./target/include/ \
45+
-output ./dns2socks.xcframework

cbindgen.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[export]
2+
include = ["dns2socks_start", "dns2socks_stop", "dns2socks_set_log_callback"]
3+
exclude = []

src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ use tokio::{
1515
net::{TcpListener, TcpStream, ToSocketAddrs, UdpSocket},
1616
};
1717
use trust_dns_proto::op::{Message, Query};
18-
pub use {
19-
::tokio_util::sync::CancellationToken,
20-
api::{dns2socks_start, dns2socks_stop},
21-
config::{ArgVerbosity, Config},
22-
dump_logger::dns2socks_set_log_callback,
23-
};
18+
19+
pub use ::tokio_util::sync::CancellationToken;
20+
pub use api::{dns2socks_start, dns2socks_stop};
21+
pub use config::{ArgVerbosity, Config};
22+
pub use dump_logger::dns2socks_set_log_callback;
2423

2524
const MAX_BUFFER_SIZE: usize = 4096;
2625

0 commit comments

Comments
 (0)