# Release and environment testing
name: Release & Environment
on:
  push:
  pull_request:

permissions:
  contents: read

concurrency:
  cancel-in-progress: true
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

jobs:
  check-git-tag:
    name: Git Version Tag Check
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

    - name: Validate release tag
      if: startsWith(github.ref, 'refs/tags/v')
      run: |
        echo "tag=${GITHUB_REF#refs/*/}"
        make -C tests checkTag
        tests/checkTag ${GITHUB_REF#refs/*/}

  environment-info:
    name: Environment Info (${{ matrix.os }})
    strategy:
      matrix:
        os: [ubuntu-latest, ubuntu-24.04, ubuntu-22.04]

    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout
      uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

    - name: Update package list
      run: sudo apt-get update

    - name: Display compiler versions
      run: |
        echo "=== Default C Compiler ==="
        type cc && which cc && cc --version
        echo "=== GCC ==="
        type gcc && which gcc && gcc --version
        echo "=== Clang ==="
        type clang && which clang && clang --version
        echo "=== Make ==="
        type make && which make && make -v
        echo "=== G++ ==="
        type g++ && which g++ && g++ --version
        echo "=== Git ==="
        type git && which git && git --version

    - name: List available package versions
      run: |
        echo "=== Available GCC Packages ==="
        apt-cache search gcc | grep "^gcc-[0-9\.]* " | sort
        echo "=== Available lib32gcc Packages (i386) ==="
        apt-cache search lib32gcc | grep "^lib32gcc-" | sort
        echo "=== Available GCC Multilib Packages ==="
        apt-cache search multilib | grep "gcc-" | sort
        echo "=== Available Clang Packages ==="
        apt-cache search clang | grep "^clang-[0-9\.]* " | sort
        echo "=== Available QEMU Packages ==="
        apt-cache search qemu | grep "^qemu-system-.*QEMU full system" | sort
