Skip to content

Merge pull request #78 from assarbad/amending-readme #16

Merge pull request #78 from assarbad/amending-readme

Merge pull request #78 from assarbad/amending-readme #16

Workflow file for this run

name: Continuous Deployment
on:
pull_request:
push:
branches:
- master
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
crate_metadata:
name: Extract crate metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract crate information
id: crate_metadata
run: |
echo "name=renamer" | tee -a $GITHUB_OUTPUT
cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT
outputs:
name: ${{ steps.crate_metadata.outputs.name }}
version: ${{ steps.crate_metadata.outputs.version }}
ensure_cargo_fmt:
name: Ensure 'cargo fmt' has been run
runs-on: ubuntu-22.04
steps:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: actions/checkout@v3
- run: cargo fmt -- --check
build:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
needs: crate_metadata
strategy:
matrix:
job:
- { target: x86_64-apple-darwin , os: macos-12 }
- { target: x86_64-pc-windows-msvc , os: windows-2019 }
- { target: x86_64-unknown-linux-musl, os: ubuntu-22.04 }
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Build
shell: bash
run: cargo build --locked --release --target=${{ matrix.job.target }}
- name: Set binary name & path
id: bin
shell: bash
run: |
# Figure out suffix of binary
EXE_suffix=""
case ${{ matrix.job.target }} in
*-pc-windows-*) EXE_suffix=".exe" ;;
esac;
# Setup paths
BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}"
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
PKG_NAME=${{ needs.crate_metadata.outputs.name }}-${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }}${EXE_suffix}
cp "$BIN_PATH" "$PKG_NAME"
if [[ ${{ runner.os }} == 'Windows' ]]; then
certutil -hashfile "$PKG_NAME" sha256 | grep -E [A-Fa-f0-9]{64} > "${PKG_NAME}.sha256"
else
shasum -a 256 "$PKG_NAME" > "${PKG_NAME}.sha256"
fi
# Let subsequent steps know where to find the binary
echo "PKG_NAME=${PKG_NAME}" | tee -a $GITHUB_OUTPUT
- name: Check for release
id: is-release
shell: bash
run: |
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/[0-9\.]* ]]; then IS_RELEASE='true' ; fi
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
- name: Publish packages
uses: softprops/action-gh-release@v1
if: steps.is-release.outputs.IS_RELEASE
with:
files: |
${{ steps.bin.outputs.PKG_NAME }}
${{ steps.bin.outputs.PKG_NAME }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}