-
Notifications
You must be signed in to change notification settings - Fork 65
215 lines (188 loc) · 6.79 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: release
on:
push:
# Enable when testing release infrastructure on a branch.
# branches:
# - gh-actions
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
version:
description: 'Override version - useful to test workflows'
required: true
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- name: Create artifacts directory
run: mkdir artifacts
- name: Mark manual
if: inputs.version != ''
run: |
echo "MANUAL=1" >> $GITHUB_ENV
- name: Get the release version from the tag
if: env.VERSION == ''
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.VERSION }}"
- name: Create GitHub release
id: release
if: env.MANUAL != '1'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
- name: Save release upload URL to artifact
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
- name: Save version number to artifact
run: echo "${{ env.VERSION }}" > artifacts/release-version
- name: Upload artifacts
if: env.MANUAL != '1'
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
build-release:
name: build-release
needs: ["create-release"]
runs-on: ${{ matrix.os }}
env:
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
MACOSX_DEPLOYMENT_TARGET: 10.9
strategy:
matrix:
build: [linux, linux-aarch64, linux-static, macos-aarch64, macos-x86, windows]
include:
- build: linux
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- build: linux-aarch64
os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
- build: linux-static
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
- build: macos-aarch64
os: macos-14 # macOS 14 is M1 runner
target: aarch64-apple-darwin
- build: macos-x86
os: macos-13
target: x86_64-apple-darwin
- build: windows
os: "windows-2019"
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Mark manual
if: inputs.version != ''
shell: bash
run: |
echo "MANUAL=1" >> $GITHUB_ENV
- name: Install Rust (Non-windows)
if: matrix.build != 'windows'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: llvm-tools
- name: Install Rust (Windows)
if: matrix.build == 'windows'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Xcode
if: matrix.build == 'macos-x86' || matrix.build == 'macos-aarch64'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Export Rust Environment Variables
if: matrix.build != 'windows'
run: |
echo "RUSTUP_HOME=$HOME/.rustup" >> $GITHUB_ENV
echo "CARGO_HOME=$HOME/.cargo" >> $GITHUB_ENV
LLVM_TOOLS_PATH=$(rustc --print sysroot)/lib/rustlib/${{ matrix.target }}/bin
echo "PATH=$LLVM_TOOLS_PATH:$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV
- name: Install Cross toolchain (zig)
if: matrix.build == 'macos-aarch64' || matrix.build == 'linux-aarch64'
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- name: Get release download URL
if: env.MANUAL != '1'
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts
- name: Set release upload URL and release version
if: env.MANUAL != '1'
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 PGO Binary (Linux)
if: matrix.build == 'linux'
shell: bash
run: |
export TOOLCHAIN=stable-x86_64-unknown-linux-gnu
export TARGET=x86_64-unknown-linux-gnu
./build_pgo.sh
env:
HOME: ${{ github.workspace }}
- name: Build PGO Binary (macOS)
if: matrix.build == 'macos-x86'
run: |
export TOOLCHAIN=stable-x86_64-apple-darwin
export TARGET=x86_64-apple-darwin
./build_pgo.sh
env:
HOME: ${{ github.workspace }}
- name: Build PGO binary (macOS AARCH64)
if: matrix.build == 'macos-aarch64'
run: |
export TOOLCHAIN=stable-aarch64-apple-darwin
export TARGET=aarch64-apple-darwin
./build_pgo.sh
- name: Build release binary (linux MUSL)
if: matrix.build == 'linux-static'
run: cargo build --target ${{ matrix.target }} --release
- name: Build release binary (Windows)
if: matrix.build == 'windows'
run: cargo build --target ${{ matrix.target }} --release --features fast-alloc
- name: Build release binary (Linux AARCH64)
if: matrix.build == 'linux-aarch64'
run: |
cargo install cargo-zigbuild
cargo zigbuild --target ${{ matrix.target }} --release --features fast-alloc
- name: Build archive
shell: bash
run: |
if [ "${{ matrix.build }}" = "windows" ]; then
echo "ASSET=target/${{ matrix.target }}/release/evtx_dump.exe" >> $GITHUB_ENV
echo "ASSET_NAME=evtx_dump-${{ env.RELEASE_VERSION }}.exe" >> $GITHUB_ENV
else
echo "ASSET=target/${{ matrix.target }}/release/evtx_dump" >> $GITHUB_ENV
echo "ASSET_NAME=evtx_dump-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/[email protected]
if: env.MANUAL != '1'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream