Skip to content

Build and release dispel #5

Build and release dispel

Build and release dispel #5

name: Build and release dispel
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
permissions:
contents: write
packages: write
jobs:
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v5
- name: Build (posix)
if: runner.os != 'Windows'
run: make
- name: Setup MSYS2 (Windows)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
make
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-libgnurx
- name: Build (Windows via MSYS2)
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
make
- name: Prepare binary
shell: bash
run: |
set -eu
mkdir -p release
TAG="${{ github.ref_name }}"
case "${{ matrix.os }}" in
windows-latest)
cp dispel.exe "release/dispel-${TAG}-windows.exe"
;;
ubuntu-latest)
cp dispel "release/dispel-${TAG}-linux"
chmod +x "release/dispel-${TAG}-linux"
;;
macos-latest)
cp dispel "release/dispel-${TAG}-macos"
chmod +x "release/dispel-${TAG}-macos"
;;
esac
- name: List release files
run: ls -l release
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: dispel-${{ matrix.os }}-${{ github.run_id }}
path: release/
publish:
name: Create GitHub Release and attach artifacts
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v5
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
pattern: dispel-*
merge-multiple: true
path: ./artifacts
- name: Create GitHub release and upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
TAG="${{ github.ref_name }}"
test -n "$(ls -A ./artifacts 2>/dev/null)" || { echo "No artifacts found."; exit 1; }
gh release create "$TAG" ./artifacts/* --generate-notes