Skip to content

Implement new interactive terminal UI #4

Implement new interactive terminal UI

Implement new interactive terminal UI #4

Workflow file for this run

name: Build and Release
on:
push:
branches: [ main ]
tags:
- 'v*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build - ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- name: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
use_cross: true
- name: macos
os: macos-latest
target: x86_64-apple-darwin
use_cross: false
- name: macos-arm
os: macos-latest
target: aarch64-apple-darwin
use_cross: false
- name: windows-x64
os: windows-latest
target: x86_64-pc-windows-msvc
use_cross: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Install musl tools (Linux)
if: matrix.platform.name == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Install cross
if: matrix.platform.use_cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Get version from Cargo.toml
id: get_version
shell: bash
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Build (cross)
if: matrix.platform.use_cross
run: |
cross build --release --target ${{ matrix.platform.target }}
- name: Build (cargo)
if: '!matrix.platform.use_cross'
run: |
cargo build --release --target ${{ matrix.platform.target }}
- name: Prepare artifacts (Unix)
if: matrix.platform.os != 'windows-latest'
run: |
cd target/${{ matrix.platform.target }}/release
# Create directory for the archive
mkdir -p mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}
# Copy binary
cp mineping mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}/
# Add README if exists
if [ -f ../../../README.md ]; then
cp ../../../README.md mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}/
fi
# Create zip archive
zip -r mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}.zip mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}
# Move to a consistent location
mv mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}.zip ../../../
- name: Prepare artifacts (Windows)
if: matrix.platform.os == 'windows-latest'
shell: pwsh
run: |
cd target\${{ matrix.platform.target }}\release
# Create directory for the archive
New-Item -ItemType Directory -Force -Path "mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}"
# Copy executable
Copy-Item "mineping.exe" -Destination "mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}\"
# Add README if exists
if (Test-Path ..\..\..\README.md) {
Copy-Item "..\..\..\README.md" -Destination "mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}\"
}
# Create zip archive
Compress-Archive -Path "mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}" -DestinationPath "mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}.zip"
# Move to root
Move-Item "mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}.zip" -Destination ..\..\..\
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}
path: mineping-${{ steps.get_version.outputs.VERSION }}-${{ matrix.platform.name }}.zip
retention-days: 7
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Display structure of downloaded files
run: ls -la ./artifacts/
- name: Create Release with GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--title "MinePing v${{ steps.get_version.outputs.VERSION }}" \
--notes # MinePing v${{ steps.get_version.outputs.VERSION }}\n\nREST API for querying Minecraft server status.\n\n## Downloads\n- **Linux**: `mineping-${{ steps.get_version.outputs.VERSION }}-linux.zip` (static binary, works on all Linux distros)\n- **macOS Intel**: `mineping-${{ steps.get_version.outputs.VERSION }}-macos.zip`\n- **macOS Apple Silicon**: `mineping-${{ steps.get_version.outputs.VERSION }}-macos-arm.zip`\n- **Windows**: `mineping-${{ steps.get_version.outputs.VERSION }}-windows-x64.zip`\n\n## Usage\n```bash\n# Default port 3000\n./mineping\n\n# Custom port\nPORT=8080 ./mineping\n```\n\nSee README for API documentation.' \
./artifacts/*/*.zip