Skip to content

Bumping CLI to v0.2.0. #16

Bumping CLI to v0.2.0.

Bumping CLI to v0.2.0. #16

Workflow file for this run

name: Release Suite
on:
push:
tags:
- cli-v*
env:
RUST_VERSION: "1.79"
jobs:
extract-version:
runs-on: ubuntu-latest
steps:
- name: Extract version
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" | sed -r 's/cli-//' >> $GITHUB_OUTPUT
id: extract_version
outputs:
VERSION: ${{ steps.extract_version.outputs.VERSION }}
build:
name: Build Release
strategy:
matrix:
arch:
- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-windows
include:
- arch: aarch64-unknown-linux-gnu
runner: ubuntu-20.04
- arch: x86_64-unknown-linux-gnu
runner: ubuntu-20.04
- arch: x86_64-apple-darwin
runner: macos-latest
- arch: x86_64-windows
runner: windows-2019
runs-on: ${{ matrix.runner }}
needs: extract-version
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Get Rust
if: matrix.arch != 'x86_64-windows'
run: |
echo Installing Rust $RUST_VERSION
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none --profile minimal
export PATH="/root/.cargo/bin:$PATH"
rustup toolchain install $RUST_VERSION
rustup default $RUST_VERSION
- name: Get Rust for Windows
if: matrix.arch == 'x86_64-windows'
run: |
echo Installing Rust $RUST_VERSION
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none --profile minimal
$env:Path += ";$env:USERPROFILE\.cargo\bin"
rustup toolchain install $RUST_VERSION
rustup default $RUST_VERSION
- name: Install deps for Linux
if: matrix.arch == 'aarch64-unknown-linux-gnu' || matrix.arch == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y libusb-1.0-0-dev libudev-dev libhidapi-dev
# ==============================
# Builds
# ==============================
- name: Remove rust-toolchain.toml
run: rm rust-toolchain.toml
- name: Build
run: cargo install --bin heritage-cli --path crates/heritage-cli --force --locked --profile release
- name: Create artifacts
if: matrix.arch != 'x86_64-windows'
run: |
mkdir artifacts
mv ~/.cargo/bin/heritage-cli ./artifacts
cd artifacts
tar -czf heritage-cli-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz heritage-cli
mv *tar.gz* ..
- name: Create artifacts Windows
if: matrix.arch == 'x86_64-windows'
run: |
mkdir artifacts
move $env:USERPROFILE/.cargo/bin/heritage-cli.exe ./artifacts
cd artifacts
Compress-Archive -Path heritage-cli.exe -DestinationPath heritage-cli-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.zip
move *zip* ..
# =======================================================================
# Upload artifacts
# This is required to share artifacts between different jobs
# =======================================================================
- name: Upload artifact
if: matrix.arch != 'x86_64-windows'
uses: actions/upload-artifact@v4
with:
name: heritage-cli-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
path: heritage-cli-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
compression-level: 0
- name: Upload artifact Windows
if: matrix.arch == 'x86_64-windows'
uses: actions/upload-artifact@v4
with:
name: heritage-cli-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.zip
path: heritage-cli-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.zip
compression-level: 0
publish-release:
name: Release
needs: [build, extract-version]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
# This is necessary for generating the changelog. It has to come before "Download Artifacts" or else it deletes the artifacts.
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
# ==============================
# Download artifacts
# ==============================
- name: Download artifacts
uses: actions/download-artifact@v4
# ==============================
# Create release draft
# ==============================
- name: Generate Full Changelog
id: changelog
run: |
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Publish Release
# The formatting here is borrowed from OpenEthereum: https://github.com/openethereum/openethereum/blob/main/.github/workflows/build.yml
env:
REPO_NAME: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
body=$(cat <<- "ENDBODY"
## All Changes
${{ steps.changelog.outputs.CHANGELOG }}
## Binaries
| System | Architecture | Binary |
|:---:|:---:|:---|
| <img src="https://simpleicons.org/icons/linux.svg" style="width: 32px;"/> | x86_64 | [heritage-cli-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/heritage-cli-${{ env.VERSION }}-x86_64-unknown-linux-gnu.tar.gz) |
| <img src="https://simpleicons.org/icons/raspberrypi.svg" style="width: 32px;"/> | aarch64 | [heritage-cli-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/heritage-cli-${{ env.VERSION }}-aarch64-unknown-linux-gnu.tar.gz) |
| <img src="https://simpleicons.org/icons/apple.svg" style="width: 32px;"/> | x86_64 | [heritage-cli-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/heritage-cli-${{ env.VERSION }}-x86_64-apple-darwin.tar.gz) |
| <img src="https://simpleicons.org/icons/windows.svg" style="width: 32px;"/> | x86_64 | [heritage-cli-${{ env.VERSION }}-x86_64-windows.zip](https://github.com/${{ env.REPO_NAME }}/releases/download/${{ env.VERSION }}/heritage-cli-${{ env.VERSION }}-x86_64-windows.zip) |
ENDBODY
)
assets=(./heritage-cli-*.tar.gz/heritage-cli-*.tar.gz)
assets+=(./heritage-cli-*.zip/heritage-cli-*.zip)
tag_name="${{ env.VERSION }}"
echo "$body" | gh release create --latest --title "Heritage CLI - $tag_name" -F "-" "$tag_name" "${assets[@]}"