Skip to content

chore: Release

chore: Release #28

Workflow file for this run

---
name: "Rust Build & Release"
# This configuration largely comes from ripgrep
on:
push:
tags:
- 'v*'
env:
RUSTFLAGS: "-D warnings"
CARGO_UNSTABLE_SPARSE_REGISTRY: true
jobs:
build_release:
name: "Build ${{ matrix.name }} binaries (cargo build)"
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: linux x64
os: ubuntu-latest
target: x86_64-unknown-linux-musl
cargo: cargo
- name: linux aarch
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cargo: cross
- name: linux arm
os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
cargo: cross
- name: macos x64
os: macos-latest
target: x86_64-apple-darwin
cargo: cargo
- name: macos aarch
os: macos-latest
target: aarch64-apple-darwin
cargo: cargo
- name: windows msvc
os: windows-latest
target: x86_64-pc-windows-msvc
cargo: cargo
- name: windows gnu
os: windows-latest
target: x86_64-pc-windows-gnu
cargo: cargo
env:
TARGET_DIR: ./target
TARGET_FLAGS: ""
steps:
- uses: actions/checkout@v4
- run: rustup default nightly && rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Configure cross
if: matrix.cargo == 'cross'
uses: taiki-e/install-action@cross
- name: Show commands
run: |
echo pwd:
pwd
echo ls:
ls
echo "cargo command is: ${{ matrix.cargo }}"
echo "target flags are: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
# Perform build
- name: Build binary
run: ${{ matrix.cargo }} build --release --verbose --target ${{ matrix.target }}
- name: Show output
run: |
ls ${{ env.TARGET_DIR }}
ls "${{ env.TARGET_DIR }}/${{ matrix.target }}"
ls "${{ env.TARGET_DIR }}/${{ matrix.target }}/release"
# Create .zip or .tar.gz file
- name: Build archive
shell: bash
run: |
echo '\nWorking directory:' && pwd
echo '\nls:' && ls
# Find the output directory with the latest timestamp
cargo_outdir="$(find "${{ env.TARGET_DIR }}" -name mpk-stamp -print0 | xargs -0 ls -t | head -n1 | xargs dirname)"
ref_name=${GITHUB_REF##*/}
# Remove leading 'v' for use where needed
ref_name_stripped=$(echo "$ref_name" | perl -0pe 's/^v//')
echo "Ref name: '$ref_name'"
echo "Ref name stripped: '$ref_name_stripped'"
staging_dir="mpk-${ref_name}-${{ matrix.target }}"
echo "STAGING_DIR=$staging_dir" >> "$GITHUB_ENV"
echo "RELEASE_VERSION=$ref_name_stripped" >> "$GITHUB_ENV"
echo "staging_dir: ${staging_dir}"
STAGING_DIR="$staging_dir" \
CARGO_ASSETDIR="$cargo_outdir" \
CARGO_BUILDDIR="${{ env.TARGET_DIR }}/${{ matrix.target }}/release" \
RELEASE_VERSION="$ref_name_stripped" \
dist/create_release.sh
# Create debian packages
if [ "${{ matrix.os }}" = 'ubuntu-latest' ]; then
echo '==== creating .deb packages ===='
# On our native platform, make sure we can install
if [ "${{ matrix.cargo }}" = 'cargo' ]; then
do_test=true
fi
# Need sudo because of `DO_TEST`, which means we need to pass all
# environment variables inside the sudo
sudo \
STAGING_DIR="$staging_dir" \
TARGET=${{ matrix.target }} \
RELEASE_VERSION="$ref_name_stripped" \
DO_TEST="$do_test" \
GITHUB_ENV="$GITHUB_ENV" \
dist/build_deb.sh
fi
# Upload to github
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_REPOSITORY: pluots/mpk
with:
body_path: RELNOTES.md
# note you'll typically need to create a personal access token
# with permissions to create releases in the other repo
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ env.ASSET }}