Skip to content

Commit

Permalink
ci: build fully static binaries in release workflow (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic authored Mar 25, 2024
1 parent 4cc8023 commit 982b356
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,62 @@ jobs:
- build: linux
os: ubuntu-latest
rust: stable
args: ""
target: x86_64-unknown-linux-gnu
vcpkg_openssl_triplet: x64-linux-release
args: "--features=openssl-static"

- build: macos
os: macos-latest
rust: stable
args: ""
target: x86_64-apple-darwin
vcpkg_openssl_triplet: x64-osx-release
args: "--features=openssl-static"

- build: windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
vcpkg_openssl_triplet: x64-windows-static
args: ""

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

- name: Install dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev libmagic-dev
- name: Install dependencies
id: vcpkg
if: runner.os == 'Windows'
uses: johnwason/vcpkg-action@v5
uses: johnwason/vcpkg-action@v6
with:
pkgs: openssl
triplet: x64-windows-release
triplet: ${{ matrix.vcpkg_openssl_triplet }}
token: ${{ github.token }}

- name: Set OPENSSL_DIR environment variable
if: runner.os == 'Windows'
shell: bash
run: echo "OPENSSL_DIR=${{ github.workspace }}\\vcpkg\\installed\\x64-windows-release" >> $GITHUB_ENV

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Build
run: cargo build --profile release-lto ${{ matrix.args }}
run: cargo build --bin yr --profile release-lto --target ${{ matrix.target }} ${{ matrix.args }}
env:
RUSTFLAGS: "-C target-feature=+crt-static"
OPENSSL_DIR: "${{ github.workspace }}/vcpkg/installed/${{ matrix.vcpkg_openssl_triplet }}"

- name: Build archive
shell: bash
run: |
set -ex
pkgname=yara-x-${{ matrix.build }}-${{ github.ref_name }}
pkgname=yara-x-${{ github.ref_name }}-${{ matrix.target }}
if [ "${{ matrix.build }}" = "windows" ]; then
7z a $pkgname.zip ./target/release-lto/yr.exe
7z a $pkgname.zip ./target/${{ matrix.target }}/release-lto/yr.exe
else
tar czf $pkgname.gzip -C target/release-lto yr
tar czf $pkgname.gzip -C target/${{ matrix.target }}/release-lto yr
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: yr-${{ matrix.build }}
name: yr-${{ matrix.target }}
path: yara-x-*

publish:
Expand Down

0 comments on commit 982b356

Please sign in to comment.