From d1de353cdcb45146681d4f2b37ccc4dbb8f2652a Mon Sep 17 00:00:00 2001 From: Richik SC Date: Fri, 1 Jan 2021 12:26:33 -0600 Subject: [PATCH] Switch to stable Rust now that v1.49 is released, simplify GitHub workflow --- .ci/cross-build.sh | 7 ---- .ci/package.sh | 17 +++++--- .github/workflows/release.yml | 78 ++++++++++++----------------------- 3 files changed, 37 insertions(+), 65 deletions(-) delete mode 100755 .ci/cross-build.sh diff --git a/.ci/cross-build.sh b/.ci/cross-build.sh deleted file mode 100755 index c24b009..0000000 --- a/.ci/cross-build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -if [[ -n "$WIN" ]]; then - sudo apt-get install gcc-mingw-w64 && - printf "[target.$WIN]\nlinker = \"x86_64-w64-mingw32-gcc\"" >> ~/.cargo/config && - cargo build --release --target=$WIN && - mv target/$WIN/release/badlogvis.exe target/release/badlogvis-$WIN.exe -fi diff --git a/.ci/package.sh b/.ci/package.sh index 698a845..2472eef 100755 --- a/.ci/package.sh +++ b/.ci/package.sh @@ -4,16 +4,21 @@ mkdir -p out/badlogvis-$TARGET cp target/release/badlogvis out/badlogvis-$TARGET/ cp .ci/install.sh out/badlogvis-$TARGET/ -if [[ -n "$ARM" ]]; then - mkdir -p out/badlogvis-$ARM - cp target/$ARM/release/badlogvis out/badlogvis-$ARM/ - cp .ci/install.sh out/badlogvis-$ARM/ +mkdir -p out/badlogvis-$SECONDARY + +if [[ "$SECONDARY" != "x86_64-pc-windows-gnu" ]]; then + cp .ci/install.sh out/badlogvis-$SECONDARY/ + cp target/$SECONDARY/release/badlogvis out/badlogvis-$SECONDARY/ +else + cp target/$SECONDARY/release/badlogvis.exe out/badlogvis-$SECONDARY/ fi cd out/ tar -czvf badlogvis-$TARGET.tar.gz badlogvis-$TARGET/ -if [[ -n "$ARM" ]]; then - tar -czvf badlogvis-$ARM.tar.gz badlogvis-$ARM/ +if [[ "$SECONDARY" != "x86_64-pc-windows-gnu" ]]; then + tar -czvf badlogvis-$SECONDARY.tar.gz badlogvis-$SECONDARY/ +else + zip -r badlogvis-$SECONDARY.zip badlogvis-$SECONDARY/ fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2983a88..8bf50a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,75 +5,49 @@ on: - 'v*' jobs: - build-macos: - name: Build for macOS - runs-on: macos-11.0 - env: - TARGET: x86_64-apple-darwin - ARM: aarch64-apple-darwin + build: + strategy: + matrix: + include: + - os: macos-11.0 + TARGET: x86_64-apple-darwin + SECONDARY: aarch64-apple-darwin + - os: ubuntu-latest + TARGET: x86_64-unknown-linux-gnu + SECONDARY: x86_64-pc-windows-gnu + name: Build (${{ matrix.os }}) + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Set Release Version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Install Rust beta + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: beta + toolchain: stable default: true - target: ${{ env.ARM }} # This is in addition to the native target + target: ${{ matrix.SECONDARY }} # This is in addition to the native target profile: minimal - - name: Build for x86_64-apple-darwin + - name: Build for ${{ matrix.TARGET }} uses: actions-rs/cargo@v1 with: command: build args: --release - - name: Build for aarch64-apple-darwin + - name: Install Windows linker + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install gcc-mingw-w64 && + printf "[x86_64-pc-windows-gnu]\nlinker = \"x86_64-w64-mingw32-gcc\"" >> ~/.cargo/config + - name: Build for ${{ matrix.SECONDARY }} uses: actions-rs/cargo@v1 with: command: build - args: --release --target ${{ env.ARM }} + args: --release --target ${{ matrix.SECONDARY }} - name: Package binaries id: package_binaries - run: .ci/package.sh - - name: Publish release with binaries - id: publish_release - uses: softprops/action-gh-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ env.RELEASE_VERSION }} - name: badlogvis ${{ env.RELEASE_VERSION }} - draft: false - prerelease: false - files: | - ./out/badlogvis-*.tar.gz - build-linux: - name: Build for Linux and Windows - runs-on: ubuntu-latest - env: - TARGET: x86_64-unknown-linux-gnu - WIN: x86_64-pc-windows-gnu - steps: - - uses: actions/checkout@v2 - - name: Set Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Install Rust beta - uses: actions-rs/toolchain@v1 - with: - toolchain: beta - default: true - target: ${{ env.WIN }} # This is in addition to the native target - profile: minimal - - name: Build for x86_64-unknown-linux-gnu - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - - name: Build for x86_64-pc-windows-gnu - id: build_windows - run: .ci/cross-build.sh - - name: Package binaries - id: package_binaries + TARGET: ${{ matrix.TARGET }} + SECONDARY: ${{ matrix.SECONDARY }} run: .ci/package.sh - name: Publish release with binaries id: publish_release @@ -86,7 +60,7 @@ jobs: draft: false prerelease: false files: | - ./target/release/badlogvis-${{ env.WIN }}.exe ./out/badlogvis-*.tar.gz + ./out/badlogvis-*.zip