Release #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| release: | |
| name: Create Release and Publish to crates.io | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Install ALSA dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libasound2-dev pkg-config | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Verify version matches Cargo.toml | |
| run: | | |
| CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2) | |
| TAG_VERSION="${{ steps.get_version.outputs.VERSION }}" | |
| if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then | |
| echo "Error: Cargo.toml version ($CARGO_VERSION) doesn't match tag version ($TAG_VERSION)" | |
| exit 1 | |
| fi | |
| - name: Check sounds directory exists | |
| run: | | |
| if [ ! -d "sounds" ]; then | |
| echo "Error: sounds/ directory not found. Please add sound files before releasing." | |
| exit 1 | |
| fi | |
| # Check for required sound files | |
| for sound in rain.mp3 thunder.mp3 campfire.mp3; do | |
| if [ ! -f "sounds/$sound" ]; then | |
| echo "Error: sounds/$sound not found" | |
| exit 1 | |
| fi | |
| done | |
| - name: Create sounds archive | |
| run: | | |
| tar -czf sounds.tar.gz sounds/ | |
| ls -lh sounds.tar.gz | |
| - name: Build project | |
| run: cargo build --release --verbose | |
| - name: Run tests | |
| run: cargo test --verbose | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: Release ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| - name: Upload sounds.tar.gz to release | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./sounds.tar.gz | |
| asset_name: sounds.tar.gz | |
| asset_content_type: application/gzip | |
| - name: Publish to crates.io | |
| run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |