diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..20c0a79 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,133 @@ +name: Release + +on: + release: + types: [published] + push: + branches: [workflow-release-test] + +env: + CARGO_TERM_COLOR: always + RUST_MIN_STACK: 16777212 + +permissions: + contents: write + +jobs: + build: + strategy: + fail-fast: false + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + include: + - platform: ubuntu-latest + artifact-path: target/release/sdl + artifact-platform-name: linux-x64 + env-command: ">> $GITHUB_ENV" + - platform: macos-latest + artifact-path: target/release/sdl + artifact-platform-name: macos-x64 + env-command: ">> $GITHUB_ENV" + - platform: windows-latest + artifact-path: target/release/sdl.exe + artifact-platform-name: windows-x64 + env-command: "| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" + + runs-on: ${{ matrix.platform }} + + timeout-minutes: 60 + + steps: + - uses: actions/checkout@v4 + + - name: Update Rust + run: rustup update + + - uses: swatinem/rust-cache@v2 + + - name: Install libssl-dev (linux-armhf) + uses: ryankurte/action-apt@v0.4.0 + if: ${{ matrix.platform == 'ubuntu-latest' }} + with: + arch: armhf + packages: "libssl-dev:armhf" + + - name: Install libssl-dev (linux-arm64) + uses: ryankurte/action-apt@v0.4.0 + if: ${{ matrix.platform == 'ubuntu-latest' }} + with: + arch: arm64 + packages: "libssl-dev:arm64" + + - name: Build, get version + run: | + cargo run --release --bin sdl -- --help + echo "SDL_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[0].version')" ${{ matrix.env-command }} + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: sdl-${{ env.SDL_VERSION }}-${{ matrix.artifact-platform-name }} + path: ${{ matrix.artifact-path }} + if-no-files-found: error + + - name: Build (macos-aarch64) + if: ${{ matrix.platform == 'macos-latest' }} + run: | + rustup target add aarch64-apple-darwin + cargo build --release --bin sdl --target aarch64-apple-darwin + + - name: Upload artifacts (macos-aarch64) + uses: actions/upload-artifact@v4 + if: ${{ matrix.platform == 'macos-latest' }} + with: + name: sdl-${{ env.SDL_VERSION }}-macos-aarch64 + path: target/aarch64-apple-darwin/release/sdl + if-no-files-found: error + + - name: Build (linux-armv7-gnueabihf) + if: ${{ matrix.platform == 'ubuntu-latest' }} + run: | + rustup target add armv7-unknown-linux-gnueabihf + sudo apt-get install -yq gcc-arm-linux-gnueabihf + export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc + cargo build --release --bin sdl --target armv7-unknown-linux-gnueabihf + + - name: Upload artifacts (linux-armv7-gnueabihf) + uses: actions/upload-artifact@v4 + if: ${{ matrix.platform == 'ubuntu-latest' }} + with: + name: sdl-${{ env.SDL_VERSION }}-linux-armv7-gnueabihf + path: target/armv7-unknown-linux-gnueabihf/release/sdl + if-no-files-found: error + + - name: Build (linux-aarch64-gnu) + if: ${{ matrix.platform == 'ubuntu-latest' }} + run: | + rustup target add aarch64-unknown-linux-gnu + sudo apt-get install -yq gcc-aarch64-linux-gnu + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc + cargo build --release --bin sdl --target aarch64-unknown-linux-gnu + + - name: Upload artifacts (linux-aarch64-gnu) + uses: actions/upload-artifact@v4 + if: ${{ matrix.platform == 'ubuntu-latest' }} + with: + name: sdl-${{ env.SDL_VERSION }}-linux-aarch64-gnu + path: target/aarch64-unknown-linux-gnu/release/sdl + if-no-files-found: error + + - name: Build (linux-x86_64-musl) + if: ${{ matrix.platform == 'ubuntu-latest' }} + run: | + rustup target add x86_64-unknown-linux-musl + sudo apt-get install -yq musl-tools + cargo build --release --bin sdl --target x86_64-unknown-linux-musl + + - name: Upload artifacts (linux-x86_64-musl) + uses: actions/upload-artifact@v4 + if: ${{ matrix.platform == 'ubuntu-latest' }} + with: + name: sdl-${{ env.SDL_VERSION }}-linux-x64-musl + path: target/x86_64-unknown-linux-musl/release/sdl + if-no-files-found: error