-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b355bac
commit 9225f8c
Showing
1 changed file
with
22 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,41 @@ | ||
name: Build and Release | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
runner: ubuntu-latest | ||
#- target: x86_64-pc-windows-gnu | ||
# runner: ubuntu-latest | ||
- target: x86_64-apple-darwin | ||
runner: macos-latest | ||
|
||
runs-on: ${{ matrix.runner }} | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Rust | ||
run: rustup target add ${{ matrix.target }} | ||
|
||
- name: Install cross (Linux/Windows only) | ||
if: matrix.target != 'x86_64-apple-darwin' | ||
run: cargo install cross --git https://github.com/cross-rs/cross | ||
|
||
- name: Install Homebrew (macOS only) | ||
if: matrix.target == 'x86_64-apple-darwin' | ||
run: | | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/runner/.bash_profile | ||
eval "$(/opt/homebrew/bin/brew shellenv)" | ||
brew update | ||
brew doctor || true | ||
- name: Install OpenSSL (macOS only) | ||
if: matrix.target == 'x86_64-apple-darwin' | ||
run: | | ||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/runner/.bash_profile | ||
eval "$(/opt/homebrew/bin/brew shellenv)" | ||
brew untap homebrew/cask || true | ||
brew untap homebrew/core || true | ||
brew install openssl@3 || brew link --force openssl@3 | ||
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV | ||
- name: Install OpenSSL (Linux only) | ||
if: matrix.target == 'x86_64-unknown-linux-gnu' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y pkg-config libssl-dev libsasl2-dev | ||
echo "OPENSSL_DIR=/usr/lib/ssl" >> $GITHUB_ENV | ||
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV | ||
- name: Install Chocolatey (Windows only) | ||
if: matrix.target == 'x86_64-pc-windows-gnu' | ||
shell: pwsh | ||
run: | | ||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | ||
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | ||
- name: Install OpenSSL (Windows only) | ||
if: matrix.target == 'x86_64-pc-windows-gnu' | ||
run: | | ||
choco install openssl | ||
echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >> $GITHUB_ENV | ||
- name: Build binary | ||
env: | ||
OPENSSL_DIR: ${{ env.OPENSSL_DIR }} # Set for all platforms to locate OpenSSL | ||
run: | | ||
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then | ||
cargo build --release --target ${{ matrix.target }}; | ||
else | ||
cross build --release --target ${{ matrix.target }}; | ||
fi | ||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
|
||
- name: Rename binary for Windows | ||
if: matrix.target == 'x86_64-pc-windows-gnu' | ||
run: mv target/${{ matrix.target }}/release/affected target/${{ matrix.target }}/release/affected.exe | ||
- name: Build | ||
run: cargo build --release | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: target/${{ matrix.target }}/release/affected* | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: target/${{ matrix.target }}/release/ | ||
name: release | ||
path: target/release/**/* | ||
|
||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: target/${{ matrix.target }}/release/**/* | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false |