Skip to content

Update Github Actions workflows #15

Update Github Actions workflows

Update Github Actions workflows #15

Workflow file for this run

---
on:
push:
# Uncomment to test against a branch
branches:
- ci
tags:
- 'v*'
jobs:
get_version:
name: Get version
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}"
build_and_upload:
name: Build and upload assets
needs: get_version
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -C strip=symbols
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get Rust target triple
id: get_target
shell: bash
run: |
echo -n 'name=' >> "${GITHUB_OUTPUT}"
rustc -vV | sed -n 's|host: ||p' >> "${GITHUB_OUTPUT}"
- 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
- name: Build archive
id: build_archive
shell: bash
run: |
base_name=ddns-updater-${{ needs.get_version.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 "name=${asset}" >> "${GITHUB_OUTPUT}"
echo "name_sha512=${asset}.sha512" >> "${GITHUB_OUTPUT}"
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.get_version.outputs.version }}
name: Version ${{ needs.get_version.outputs.version }}
draft: true
files: |
${{ steps.build_archive.outputs.name }}
${{ steps.build_archive.outputs.name_sha512 }}