TUT/.github/workflows/release.yml
m1ngsama ffacdc8c3e ci: Auto release on push to main with multi-platform builds
- Change trigger from tags to push on main branch
- Add matrix build for macOS and Linux platforms
- Use softprops/action-gh-release for creating releases
- Auto-generate version using date and commit hash
- Upload platform-specific binaries to release
- Fix CMakeLists.txt to conditionally set Homebrew path for macOS only
2025-11-20 11:45:50 +08:00

95 lines
2.3 KiB
YAML

name: Build and Release
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
name: macos
- os: ubuntu-latest
name: linux
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install cmake ncurses curl
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y cmake libncursesw5-dev libcurl4-openssl-dev
- name: Configure CMake
run: |
mkdir -p build
cd build
cmake ..
- name: Build project
run: |
cd build
cmake --build .
- name: Rename binary with platform suffix
run: |
mv build/nbtca_tui build/nbtca_tui-${{ matrix.name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nbtca_tui-${{ matrix.name }}
path: build/nbtca_tui-${{ matrix.name }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate version
id: version
run: |
VERSION="v$(date +'%Y.%m.%d')-$(git rev-parse --short HEAD)"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.VERSION }}
name: Release ${{ steps.version.outputs.VERSION }}
body: |
Automated release for commit ${{ github.sha }}
## Download
- **macOS**: `nbtca_tui-macos`
- **Linux**: `nbtca_tui-linux`
## Build from source
See the [README](https://github.com/${{ github.repository }}/blob/main/README.md) for build instructions.
files: |
artifacts/nbtca_tui-macos/nbtca_tui-macos
artifacts/nbtca_tui-linux/nbtca_tui-linux
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}