release #31
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
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 |