-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (107 loc) · 4.26 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
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 }}
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: 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: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/affected*
release:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin ]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/
- name: List directory contents
run: ls -la target/${{ matrix.target }}/release/
- name: Upload release asset for macOS/Linux
if: matrix.target != 'x86_64-pc-windows-gnu'
uses: softprops/action-gh-release@v1
with:
files: target/${{ matrix.target }}/release/affected
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release asset for Windows
if: matrix.target == 'x86_64-pc-windows-gnu'
uses: softprops/action-gh-release@v1
with:
files: target/${{ matrix.target }}/release/affected.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}