Release #5
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
| # SPDX-License-Identifier: MIT | |
| # SPDX-FileCopyrightText: 2025 Alexander Minges | |
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| checks: | |
| name: Lint & Test (Linux) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Cache cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install stable toolchain | |
| uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Cargo fmt | |
| run: cargo fmt --all -- --check | |
| - name: Cargo clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Cargo test | |
| run: cargo test --all | |
| build: | |
| name: Build ${{ matrix.target }} | |
| needs: checks | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| archive: tar.gz | |
| rustflags: -C target-feature=-crt-static -Clink-arg=-lm | |
| linux: true | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| archive: tar.gz | |
| rustflags: "" | |
| linux: true | |
| - runner: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| archive: zip | |
| rustflags: "" | |
| linux: false | |
| runs-on: ${{ matrix.runner }} | |
| env: | |
| TARGET: ${{ matrix.target }} | |
| RUSTFLAGS: ${{ matrix.rustflags }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install stable toolchain | |
| uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| - name: Install Linux build deps | |
| if: matrix.linux | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| pkg-config \ | |
| libx11-dev libxcursor-dev libxrandr-dev libxi-dev \ | |
| libgl1-mesa-dev libasound2-dev libudev-dev \ | |
| libwayland-dev libxkbcommon-dev | |
| if [ "${TARGET}" = "x86_64-unknown-linux-musl" ]; then | |
| sudo apt-get install -y musl-tools musl-dev | |
| fi | |
| - name: Configure musl linker | |
| if: matrix.target == 'x86_64-unknown-linux-musl' | |
| run: echo "CC_x86_64_unknown_linux_musl=musl-gcc" >> $GITHUB_ENV | |
| - name: Cache cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build release | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package artifact (Linux) | |
| if: matrix.archive == 'tar.gz' | |
| run: | | |
| bin_path=target/$TARGET/release/elnpack | |
| pkg_dir=package-linux | |
| mkdir -p "$pkg_dir" | |
| cp "$bin_path" "$pkg_dir/" | |
| cp README.md LICENSE "$pkg_dir/" | |
| tar -czf elnpack-${{ github.ref_name }}-$TARGET.tar.gz -C "$pkg_dir" . | |
| - name: Package artifact (Windows) | |
| if: matrix.archive == 'zip' | |
| shell: pwsh | |
| run: | | |
| $binPath = "target/${env:TARGET}/release/elnpack.exe" | |
| $pkgDir = "package-windows" | |
| New-Item -ItemType Directory -Force -Path $pkgDir | Out-Null | |
| Copy-Item $binPath "$pkgDir/" | |
| Copy-Item "README.md","LICENSE" "$pkgDir/" | |
| Compress-Archive -Path "$pkgDir/*" -DestinationPath "elnpack-${{ github.ref_name }}-${env:TARGET}.zip" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: elnpack-${{ github.ref_name }}-${{ matrix.target }} | |
| path: | | |
| elnpack-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive }} | |
| publish: | |
| name: Publish Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: List artifacts | |
| run: ls -R dist | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| find . -maxdepth 2 -type f \( -name "*.tar.gz" -o -name "*.zip" \) | xargs sha256sum > SHA256SUMS | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| files: | | |
| dist/**/* | |
| draft: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |