Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

name: Release

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:

env:
binary_name: the_dude_to_human
binary_version: false
binary_checksum: true

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: amd64
builder: ubuntu-latest

- os: linux
arch: arm64
builder: ubuntu-24.04-arm

- os: macos
arch: amd64
builder: macos-13

- os: macos
arch: arm64
builder: macos-latest

- os: windows
arch: amd64
builder: windows-latest


name: ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.builder }}

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Compute binary name
shell: bash
run: |
github_ref_name="${GITHUB_REF_NAME/\//-}"
if [[ "${{ env.binary_version }}" == "true" ]]; then
binary_name="${{ env.binary_name }}-${github_ref_name}-${{ matrix.os }}-${{ matrix.arch }}"
else
binary_name="${{ env.binary_name }}-${{ matrix.os }}-${{ matrix.arch }}"
fi
if [[ ${{ matrix.os }} == "windows" ]]; then
binary_name="${binary_name}.exe"
fi
echo "binary_name=${binary_name}" >>$GITHUB_ENV

- name: Build
shell: bash
run: |
cmake -S . -B build
cmake --build build --target the_dude_to_human
if [[ ${{ matrix.os }} == "windows" ]]; then
mv build/bin/Debug/the_dude_to_human.exe ${{ env.binary_name }}
else
mv build/bin/the_dude_to_human ${{ env.binary_name }}
fi

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ env.binary_name }}
path: ${{ env.binary_name }}*
retention-days: 30

release:
runs-on: ubuntu-latest
needs: build
if: success() || failure()
steps:
- name: Download binaries
uses: actions/download-artifact@v4
with:
pattern: release*
merge-multiple: true
path: /tmp/release

- name: Files and checksum
run: |
cd /tmp/release

for file in ${{ env.binary_name }}*; do
if [[ "${file}" == *".exe"* ]]; then
mv "${file}" ${{ env.binary_name }}.exe
zip "${file%.*}.zip" "${{ env.binary_name }}.exe"
rm -f "${{ env.binary_name }}.exe"
else
chmod 755 "${file}"
mv "${file}" "${{ env.binary_name }}"
tar cfz "${file}.tar.gz" "${{ env.binary_name }}"
rm -f "${{ env.binary_name }}"
fi
done

if [[ ${{ env.binary_checksum }} == 'true' ]]; then
for file in ${{ env.binary_name }}*; do
sha256sum "${file}" >"${file}.sha256"
done
fi

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: /tmp/release/
retention-days: 30

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
/tmp/release/*
make_latest: true
Loading