.github/workflows/release.yml #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
on: | |
push: | |
# Uncomment to test against a branch | |
#branches: | |
# - ci | |
tags: | |
- 'v*' | |
jobs: | |
create_release: | |
name: Create GitHub release | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- name: Get version from tag | |
id: get_version | |
run: | | |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
version=${GITHUB_REF#refs/tags/v} | |
else | |
version=0.0.0-${GITHUB_REF#refs/heads/} | |
fi | |
echo "version=${version}" >> "${GITHUB_OUTPUT}" | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.get_version.outputs.version }} | |
name: Version ${{ steps.get_version.outputs.version }} | |
build_and_upload: | |
name: Build and upload assets | |
needs: create_release | |
runs-on: ${{ matrix.os }} | |
env: | |
CARGO_TERM_COLOR: always | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
- name: Get Rust LLVM target triple | |
id: get_target | |
shell: bash | |
run: | | |
echo -n 'name=' >> "${GITHUB_OUTPUT}" | |
RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json \ | |
| jq -r '."llvm-target"' \ | |
>> "${GITHUB_OUTPUT}" | |
- name: Install clippy | |
run: rustup component add clippy | |
- name: Run tests in release mode | |
env: | |
RUST_BACKTRACE: 1 | |
run: | | |
cargo clippy --workspace --release -- -D warnings | |
cargo test --workspace --release | |
- name: Build in release mode | |
run: cargo build --release --verbose | |
- name: Strip release binary (non-Windows) | |
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | |
run: strip target/release/ddns-updater | |
- name: Build archive | |
shell: bash | |
run: | | |
base_name=ddns-updater-${{ needs.create_release.outputs.version }}-${{ steps.get_target.outputs.name }} | |
mkdir "${base_name}" | |
cp {README.md,LICENSE} "${base_name}/" | |
if [[ "${{ matrix.os }}" == windows-* ]]; then | |
cp target/release/ddns-updater.exe "${base_name}/" | |
asset="${base_name}.zip" | |
7z a "${asset}" "${base_name}" | |
else | |
cp target/release/ddns-updater "${base_name}/" | |
asset="${base_name}.tar.xz" | |
tar -Jcvf "${asset}" "${base_name}" | |
fi | |
openssl sha512 -r "${asset}" | sed 's/\*/ /' > "${asset}.sha512" | |
echo "ASSET=${asset}" >> "${GITHUB_ENV}" | |
echo "ASSET_SHA512=${asset}.sha512" >> "${GITHUB_ENV}" | |
- name: Upload release assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ needs.create_release.outputs.version }} | |
files: | | |
${{ env.ASSET }} | |
${{ env.ASSET_SHA512 }} |