Skip to content

release

release #23

Workflow file for this run

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-static, macos, macos-m1, windows]
include:
- build: linux
os: ubuntu-18.04
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-static
os: ubuntu-18.04
rust: stable
target: x86_64-unknown-linux-musl
- build: macos-m1
os: macos-latest
rust: stable
target: aarch64-apple-darwin
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: windows
os: "windows-2019"
rust: stable
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
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- name: Install Cross toolchain (zig)
if: matrix.build == 'macos-m1'
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- name: Install Cross toolchain (cargo-zigbuild)
if: matrix.build == 'macos-m1'
shell: bash
run: |
cargo install cargo-zigbuild
- 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'
run: |
./build_pgo.sh
env:
HOME: ${{ github.workspace }}
- name: Build release binary
if: matrix.build == 'macos' || matrix.build == 'windows' || matrix.build == 'linux-static'
run: cargo build --target ${{ matrix.target }} --release --features fast-alloc
- name: Build release binary (macos-m1)
if: matrix.build == 'macos-m1'
run: 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