Skip to content

Release 0.1.14

Release 0.1.14 #22

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version for the release'
required: true
description:
description: 'Description for the release'
required: true
push:
tags:
- 'v*.*.*'
env:
CARGO_TERM_COLOR: always
VERSION: ${{ github.event.inputs.version || '' }}
DESCRIPTION: ${{ github.event.inputs.description || '' }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [stable]
steps:
- uses: actions/checkout@v2
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
cache-targets: true
shared-key: ${{ runner.os }}-rust-${{ matrix.rust }}
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- name: Build
id: build
shell: bash
run: |
cargo build --release
TARGET=$(rustc -vV | sed -n 's|host: ||p')
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: Archive
shell: bash
env:
TARGET: ${{ steps.build.outputs.target }}
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
mv target/release/tpm.exe target/release/tpm-${{ env.TARGET }}.exe
tar czvf tpm-${{ env.TARGET }}.tar.gz -C target/release tpm-${{ env.TARGET }}.exe
else
mv target/release/tpm target/release/tpm-${{ env.TARGET }}
tar czvf tpm-${{ env.TARGET }}.tar.gz -C target/release tpm-${{ env.TARGET }}
fi
- name: Upload Artifacts
env:
TARGET: ${{ steps.build.outputs.target }}
uses: actions/upload-artifact@v2
with:
name: tpm-${{ env.TARGET }}
path: tpm-${{ env.TARGET }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts/
- name: Format
id: format
run: |
# if the version is not set, use the latest tag
if [[ -z "${{ env.VERSION }}" ]]; then
export VERSION="$(git describe --tags --abbrev=0)"
else
export VERSION="${{ env.VERSION }}"
fi
# if the description is not set, use the message of the latest tag. if there is no tag message, use the commit message
if [[ -z "${{ env.DESCRIPTION }}" ]]; then
export DESCRIPTION="$(git tag -l --format='%(contents)' $VERSION | xargs)"
if [[ -z "$DESCRIPTION" ]]; then
export DESCRIPTION="$(git log -1 --pretty=%B) | xargs"
fi
else
export DESCRIPTION="${{ env.DESCRIPTION }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: create_release
uses: ncipollo/release-action@v1
with:
name: Release ${{ steps.format.outputs.version }}
tag: ${{ steps.format.outputs.version }}
body: ${{ steps.format.outputs.description }}
draft: false
prerelease: false
artifacts: "artifacts/**/*.tar.gz"