Skip to content

Commit

Permalink
remove strip
Browse files Browse the repository at this point in the history
  • Loading branch information
sword-jin committed Jul 13, 2024
1 parent b729be7 commit 313a689
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 41 deletions.
6 changes: 4 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ updates:
directory: "/"
schedule:
interval: weekly
timezone: Etc/UTC
open-pull-requests-limit: 10
groups:
github-actions:
patterns: ["*"]

52 changes: 19 additions & 33 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
build-release:
name: build-release
needs: [ "create-release" ]
permissions:
contents: write
env:
# For some builds, we use cross to test on 32-bit and big-endian
# systems.
Expand All @@ -67,8 +69,6 @@ jobs:
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
# The name of the executable to expect
EXE_NAME: ein
strategy:
matrix:
build: [ linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc ]
Expand Down Expand Up @@ -104,13 +104,22 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install packages (Ubuntu)
# Because openssl doesn't work on musl by default, we resort to max-pure. And that won't need any dependency, so we can skip this.continue-on-error
# Once we want to support better zlib performance, we might have to re-add it.
if: matrix.os == 'ubuntu-latest-disabled'
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- name: compile protobuf
run: |
protoc --descriptor_set_out=./tunneld-protocol/src/message.bin --proto_path=tunneld-protocol/src message.proto
- name: Install Rust
uses: dtolnay/rust-toolchain@master
Expand All @@ -126,11 +135,6 @@ jobs:
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
Expand All @@ -146,53 +150,35 @@ jobs:
- name: Set release upload URL and release version
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
echo "release upload url: $RELEASE_UPLOAD_URL"
release_version="$(cat artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "release version: $RELEASE_VERSION"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}

- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip target/${{ matrix.target }}/release/${{ env.EXE_NAME }} target/${{ matrix.target }}/release/gix

- name: Strip release binary (arm)
if: matrix.build == 'linux-arm'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/${{ env.EXE_NAME }} \
/target/arm-unknown-linux-gnueabihf/release/gix
- name: Build archive
shell: bash
run: |
staging="tunneld-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"
cp {README.md,LICENSE-*,CHANGELOG.md} "$staging/"
cp {README.md,LICENSE} "$staging/"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/release/${{ env.EXE_NAME }}.exe target/release/gix.exe "$staging/"
cp target/${{ matrix.target }}/release/tunneld.exe target/${{ matrix.target }}/release/tunnel.exe "$staging/"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp target/${{ matrix.target }}/release/${{ env.EXE_NAME }} target/${{ matrix.target }}/release/gix "$staging/"
cp target/${{ matrix.target }}/release/tunneld target/${{ matrix.target }}/release/tunnel "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
token: ${{ secrets.GITHUB_TOKEN }}
files: ${{ env.ASSET }}
tag_name: ${{ env.RELEASE_VERSION }}

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
*.txt
*.txt
*.bin
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tunneld-pkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ futures = "0.3.30"
bytes = "1.6.0"

[features]
debug=[]
debug=[]
1 change: 1 addition & 0 deletions tunneld-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ prost = "0.12.6"

[build-dependencies]
tonic-build = "0.11.0"
which = "6.0.1"
22 changes: 19 additions & 3 deletions tunneld-protocol/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
use std::io::Result;

use which::which;

fn main() -> Result<()> {
tonic_build::configure()
.protoc_arg("--experimental_allow_proto3_optional")
.compile(&["src/message.proto"], &["src/"])?;
let builder = tonic_build::configure().protoc_arg("--experimental_allow_proto3_optional");

match which("protoc") {
Ok(_) => {
println!("found protoc");
builder.compile(&["src/message.proto"], &["src/"])?;
}
Err(_) => {
println!("since there is no protoc in the path, we skip the protoc run");
println!("protoc --descriptor_set_out=message.bin --proto_path=. message.proto");
builder
.skip_protoc_run()
.file_descriptor_set_path("src/message.bin")
.compile(&["src/message.bin"], &["src/"])?;
}
}

Ok(())
}
2 changes: 1 addition & 1 deletion tunneld-protocol/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod pb {
tonic::include_proto!("message");
tonic::include_proto!("message");
}

// before connectrpc releases rust version, we validate the message by ourselves
Expand Down

0 comments on commit 313a689

Please sign in to comment.