audium 2.0.0

A terminal music app
name: Release

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

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-24.04

    env:
      target: x86_64-unknown-linux-gnu
      artifact_name: audium-x86_64-unknown-linux-gnu
      archive_name: audium-${{ github.ref_name }}-x86_64-linux.tar.gz

    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ env.target }}

      - name: Install Linux build dependencies (alsa-lib)
        run: |
          sudo apt-get update
          sudo apt-get install -y libasound2-dev

      - name: Build release binary
        run: cargo build --release --target ${{ env.target }}

      - name: Prepare and compress binary
        run: |
          mkdir -p artifacts
          cp target/${{ env.target }}/release/audium artifacts/${{ env.artifact_name }}
          chmod +x artifacts/${{ env.artifact_name }}

          # Create compressed archive with clean name
          cd artifacts
          tar -czf ${{ env.archive_name }} ${{ env.artifact_name }}
          ls -lh

      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ env.artifact_name }}
          path: artifacts/${{ env.archive_name }}

  release:
    needs: build
    runs-on: ubuntu-latest

    steps:
      - name: Download all built archives
        uses: actions/download-artifact@v8
        with:
          name: audium-x86_64-unknown-linux-gnu
          path: artifacts

      - name: Create draft GitHub Release
        uses: softprops/action-gh-release@v3
        with:
          tag_name: ${{ github.ref_name }}
          name: Audium ${{ github.ref_name }}
          draft: true
          generate_release_notes: true
          files: |
            artifacts/audium-${{ github.ref_name }}-x86_64-linux.tar.gz