diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c52014..d0e7a33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,195 +1,509 @@ -name: Release -on: - # schedule: - # - cron: '0 0 * * *' # midnight UTC +# Taken from: https://github.com/sharkdp/hyperfine +name: release + +env: + MIN_SUPPORTED_RUST_VERSION: "1.56.0" + CICD_INTERMEDIATES_DIR: "_cicd-intermediates" + RUST_BACKTRACE: 1 +on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - ## - release + - 'v[0-9]+.[0-9]+.[0-9]+' + -env: - BIN_NAME: witme - PROJECT_NAME: witme - REPO_NAME: ahalabs/witme jobs: - dist: - name: Dist - runs-on: ${{ matrix.os }} + build: + name: ${{ matrix.job.target }} (${{ matrix.job.os }}) + runs-on: ${{ matrix.job.os }} strategy: - fail-fast: false # don't fail other jobs if one fails + fail-fast: false matrix: - build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows, aarch64-macos] #, x86_64-win-gnu, win32-msvc - include: - - build: x86_64-linux - os: ubuntu-20.04 - rust: stable - target: x86_64-unknown-linux-gnu - cross: false - - build: aarch64-linux - os: ubuntu-20.04 - rust: stable - target: aarch64-unknown-linux-gnu - cross: true - - build: x86_64-macos - os: macos-latest - rust: stable - target: x86_64-apple-darwin - cross: false - - build: x86_64-windows - os: windows-2019 - rust: stable - target: x86_64-pc-windows-msvc - cross: false - - build: aarch64-macos - os: macos-latest - rust: stable - target: aarch64-apple-darwin - # - build: x86_64-win-gnu - # os: windows-2019 - # rust: stable-x86_64-gnu - # target: x86_64-pc-windows-gnu - # - build: win32-msvc - # os: windows-2019 - # rust: stable - # target: i686-pc-windows-msvc + job: + # Tier 1 + # DONE: Compiles + - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: i686-pc-windows-gnu , os: windows-2019 } + # DONE: Compiles + #- { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: i686-pc-windows-msvc , os: windows-2019 } + # DONE: Compiles + - { target: x86_64-apple-darwin , os: macos-10.15 } + # DONE: Compiles + #- { target: x86_64-pc-windows-gnu , os: windows-2019 } + # DONE: Compiles + - { target: x86_64-pc-windows-msvc , os: windows-2019 } + # DONE: Compiles + - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 } + # Tier 2 with Host Tools + # DONE: Compiles + - { target: aarch64-apple-darwin , os: macos-11.0 } + # DONE: Compiles + #- { target: aarch64-pc-windows-msvc , os: windows-2019 } + # DONE: Compiles + #- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: arm-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: armv7-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: mips-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: mips64-unknown-linux-gnuabi64 , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: mips64el-unknown-linux-gnuabi64 , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: mipsel-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: powerpc-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: powerpc64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: powerpc64le-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + + # DONE: Compiles + + # DONE: Compiles + #- { target: x86_64-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + # - { target: x86_64-unknown-illumos , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: arm-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: x86_64-unknown-netbsd , os: ubuntu-20.04, use-cross: true } + # Tier 2 + # DONE: Compiles + #- { target: aarch64-apple-ios , os: macos-11 } + # DONE: Compiles + #- { target: aarch64-apple-ios-sim , os: macos-11 } + # TODO: needs cc + # - { target: aarch64-fuchsia , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: aarch64-linux-android , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: aarch64-unknown-none-softfloat , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: aarch64-unknown-none , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: arm-linux-androideabi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: arm-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: arm-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: armebv7r-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: armebv7r-none-eabihf , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: armv5te-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: armv5te-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: armv7-linux-androideabi , os: ubuntu-20.04, use-cross: true } + # TODO: needs docker image for cross + # - { target: armv7-unknown-linux-gnueabi , os: ubuntu-20.04 } + # TODO: needs docker image for cross + # - { target: armv7-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: armv7-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: armv7a-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: armv7r-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: armv7r-none-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: needs emcc linker + # - { target: asmjs-unknown-emscripten , os: ubuntu-20.04, use-cross: true } + # TODO: needs linker + # - { target: i586-pc-windows-msvc , os: windows-2019 } + # DONE: Compiles + #- { target: i586-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: i586-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: i686-linux-android , os: ubuntu-20.04, use-cross: true } + # TODO: needs cc + # - { target: i686-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: mips-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: needs docker image + # - { target: mips64-unknown-linux-muslabi64 , os: ubuntu-20.04, use-cross: true } + # TODO: needs docker image + # - { target: mips64el-unknown-linux-muslabi64 , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: mipsel-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # DONE: Only emits Assembly + # - { target: nvptx64-nvidia-cuda , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv32i-unknown-none-elf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv32imac-unknown-none-elf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv32imc-unknown-none-elf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv64gc-unknown-none-elf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv64imac-unknown-none-elf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: sparc64-unknown-linux-gnu , os: ubuntu-20.04 } + # TODO: investigate + # - { target: sparcv9-sun-solaris , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv6m-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv7em-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv7em-none-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: requires cc + # - { target: thumbv7m-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv7neon-linux-androideabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv7neon-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv8m.base-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv8m.main-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv8m.main-none-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: wasm32-unknown-emscripten , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: wasm32-unknown-unknown , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: wasm32-wasi , os: ubuntu-20.04, use-cross: true } + # DONE: Compiles + #- { target: x86_64-apple-ios , os: macos-10.15 } + # TODO: investigate + # - { target: x86_64-fortanix-unknown-sgx , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-fuchsia , os: ubuntu-20.04 } + # DONE: Compiles + #- { target: x86_64-linux-android , os: ubuntu-20.04, use-cross: true } + # TODO: missing -lsocket -lposix4 -lmem + # - { target: x86_64-pc-solaris , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-linux-gnux32 , os: ubuntu-20.04 } + # TODO: investigate + # - { target: x86_64-unknown-redox , os: ubuntu-20.04, use-cross: true } + # Tier 3 + # TODO: investigate + # - { target: aarch64-apple-ios-macabi , os: macos-11 } + # TODO: investigate + # - { target: aarch64-apple-tvos , os: macos-11 } + # TODO: investigate + # - { target: aarch64-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: aarch64-unknown-hermit , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: aarch64-unknown-uefi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: aarch64-linux-gnu_ilp32 , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: aarch64_be-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv4t-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv5te-unknown-linux-uclibceabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv6-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv6-unknown-netbsd-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv7-apple-ios , os: macos-10.15 } + # TODO: investigate + # - { target: armv7-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv7-unknown-netbsd-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv7-wrs-vxworks-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv7a-none-eabihf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: armv7s-apple-ios , os: macos-10.15 } + # TODO: investigate + # - { target: avr-unknown-gnu-atmega328 , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: bpfeb-unknown-none , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: bpfel-unknown-none , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: hexagon-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: i386-apple-ios , os: macos-10.15 } + # TODO: investigate + # - { target: i686-apple-darwin , os: macos-10.15 } + # DONE: Compiles + #- { target: i686-pc-windows-msvc , os: windows-2019 } + # TODO: investigate + # - { target: i686-unknown-haiku , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: i686-unknown-netbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: i686-unknown-openbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: i686-unknown-uefi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: i686-uwp-windows-gnu , os: windows-2019 } + # TODO: investigate + # - { target: i686-uwp-windows-msvc , os: windows-2019 } + # TODO: investigate + # - { target: i686-wrs-vxworks , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mips-unknown-linux-uclibc , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsel-sony-psp , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsel-unknown-linux-uclibc , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsel-unknown-none , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsisa32r6-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsisa32r6el-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsisa64r6-unknown-linux-gnuabi64 , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: mipsisa64r6el-unknown-linux-gnuabi64, os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: msp430-none-elf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc-unknown-linux-gnuspe , os: ubuntu-20.04 } + # TODO: investigate + # - { target: powerpc-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc-unknown-netbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc-unknown-openbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc-wrs-vxworks-spe , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc-wrs-vxworks , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc64-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc64le-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc-unknown-freebsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc64-wrs-vxworks , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: powerpc64le-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv32gc-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv32gc-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv32imc-esp-espidf , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: riscv64gc-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: s390x-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: sparc-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: sparc64-unknown-netbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: sparc64-unknown-openbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv4t-none-eabi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: thumbv7a-pc-windows-msvc , os: windows-2019 } + # TODO: investigate + # - { target: thumbv7a-uwp-windows-msvc , os: windows-2019 } + # TODO: investigate + # - { target: thumbv7neon-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: wasm64-unknown-unknown , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-apple-ios-macabi , os: macos-10.15 } + # TODO: investigate + # - { target: x86_64-apple-tvos , os: macos-10.15 } + # TODO: investigate + # - { target: x86_64-pc-windows-msvc , os: windows-2019 } + # DONE: Compiles with no_std + # - { target: x86_64-sun-solaris , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-dragonfly , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-haiku , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-hermit , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-l4re-uclibc , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-none-hermitkernel , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-none-linuxkernel , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-openbsd , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-unknown-uefi , os: ubuntu-20.04, use-cross: true } + # TODO: investigate + # - { target: x86_64-uwp-windows-gnu , os: windows-2019 } + # TODO: investigate + # - { target: x86_64-uwp-windows-msvc , os: windows-2019 } + # TODO: investigate + # - { target: x86_64-wrs-vxworks , os: ubuntu-20.04, use-cross: true } - steps: - - name: Checkout sources - uses: actions/checkout@v2 - with: - submodules: true - - name: Install ${{ matrix.rust }} toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} - override: true - - - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.cross }} - command: test - args: --release --locked --target ${{ matrix.target }} - - - name: Build release binary - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.cross }} - command: build - args: --release --locked --target ${{ matrix.target }} - - - name: Strip release binary (linux and macos) - if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos' || matrix.build == 'aarch64-macos' - run: strip "target/${{ matrix.target }}/release/$BIN_NAME" - - - name: Strip release binary (arm) - if: matrix.build == 'aarch64-linux' - run: | - docker run --rm -v \ - "$PWD/target:/target:Z" \ - rustembedded/cross:${{ matrix.target }} \ - aarch64-linux-gnu-strip \ - /target/${{ matrix.target }}/release/$BIN_NAME - - name: Build archive - shell: bash - run: | - mkdir dist - if [ "${{ matrix.os }}" = "windows-2019" ]; then - cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/" - else - cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/" - fi - - uses: actions/upload-artifact@v2.2.4 - with: - name: bins-${{ matrix.build }} - path: dist - - publish: - name: Publish - needs: [dist] - runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - with: - submodules: false + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Install prerequisites + shell: bash + run: | + case ${{ matrix.job.target }} in + aarch64-linux-musl) sudo apt-get -y update ; sudo apt-get -y install musl-dev ;; + arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf export cc="gcc-arm-linux-gnueabihf" ;; + aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ; export cc="gcc-aarch64-linux-gnu" ;; + powerpc-unknown-linux-gnuspe) sudo apt-get -y update ; sudo apt-get -y install gcc-powerpc-linux-gnuspe ; export cc="gcc-powerpc-linux-gnuspe" ;; + sparc-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install libc6-dev-sparc-sparc64-cross libc6-sparc-sparc64-cross ;; + armv7-unknown-linux-gnueabi) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabi ; export cc="gcc-arm-linux-gnueabi" ;; + x86_64-unknown-linux-gnux32) sudo apt-get -y update ; sudo apt-get -y install gcc-x86-64-linux-gnux32 ; export cc="gcc-x86-64-linux-gnux32" ;; + sparc64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-sparc64-linux-gnu ; export cc="gcc-sparc64-linux-gnu" ;; + i686-pc-windows-gnu) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;; + i686-pc-windows-msvc) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;; + i586-pc-windows-msvc) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;; + esac + - name: Extract crate information + shell: bash + run: | + echo "PROJECT_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV + echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV + echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV + echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV + - name: Install latest nightly + uses: actions-rs/toolchain@v1 + with: + target: ${{ matrix.job.target }} + toolchain: nightly + override: true + profile: minimal - - uses: actions/download-artifact@v2 - # with: - # path: dist - # - run: ls -al ./dist - - run: ls -al bins-* + - name: Show version information (Rust, cargo, Gcc) + shell: bash + run: | + cc --version || true + rustup -V + rustup toolchain list + rustup default + cargo -V + rustc -V + - name: Show rustc --version --verbose + shell: bash + run: rustc --version --verbose - - name: Calculate tag name - run: | - name=dev - if [[ $GITHUB_REF == refs/tags/v* ]]; then - name=${GITHUB_REF:10} - fi - echo ::set-output name=val::$name - echo TAG=$name >> $GITHUB_ENV - id: tagname + - name: Build + uses: actions-rs/cargo@v1 + with: + use-cross: ${{ matrix.job.use-cross }} + command: build + args: --locked --release --target=${{ matrix.job.target }} - - name: Build archive - shell: bash - run: | - set -ex - rm -rf tmp - mkdir tmp - mkdir dist - for dir in bins-* ; do - platform=${dir#"bins-"} - if [[ $platform =~ "windows" ]]; then - exe=".exe" - fi - pkgname=$PROJECT_NAME-$TAG-$platform - mkdir tmp/$pkgname - # cp LICENSE README.md tmp/$pkgname - mv bins-$platform/$BIN_NAME$exe tmp/$pkgname - chmod +x tmp/$pkgname/$BIN_NAME$exe - if [ "$exe" = "" ]; then - tar cJf dist/$pkgname.tar.xz -C tmp $pkgname - else - (cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname) - fi - done - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: dist/* - file_glob: true - tag: ${{ steps.tagname.outputs.val }} - overwrite: true + - name: Strip debug information from executable + id: strip + shell: bash + run: | + # Figure out suffix of binary + EXE_suffix="" + case ${{ matrix.job.target }} in + *-pc-windows-*) EXE_suffix=".exe" ;; + esac; + # Figure out what strip tool to use if any + STRIP="strip" + case ${{ matrix.job.target }} in + arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;; + aarch64-pc-*) STRIP="" ;; + aarch64-unknown-*) STRIP="" ;; + armv7-unknown-*) STRIP="" ;; + mips-unknown-*) STRIP="" ;; + mips64-unknown-*) STRIP="" ;; + mips64el-unknown-*) STRIP="" ;; + mipsel-unknown-*) STRIP="" ;; + powerpc-unknown-*) STRIP="" ;; + powerpc64-unknown-*) STRIP="" ;; + powerpc64le-unknown-*) STRIP="" ;; + riscv64gc-unknown-*) STRIP="" ;; + s390x-unknown-*) STRIP="" ;; + x86_64-unknown-freebsd) STRIP="" ;; + x86_64-unknown-illumos) STRIP="" ;; + aarch64-linux-android) STRIP="" ;; + arm-linux-androideabi) STRIP="" ;; + armv5te-unknown-linux-gnueabi) STRIP="" ;; + armv5te-unknown-linux-musleabi) STRIP="" ;; + armv7-linux-androideabi) STRIP="" ;; + esac; + # Setup paths + BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/" + mkdir -p "${BIN_DIR}" + BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}" + BIN_PATH="${BIN_DIR}/${BIN_NAME}" + TRIPLET_NAME="${{ matrix.job.target }}" + # Copy the release build binary to the result location + cp "target/$TRIPLET_NAME/release/${BIN_NAME}" "${BIN_DIR}" + # Also strip if possible + if [ -n "${STRIP}" ]; then + "${STRIP}" "${BIN_PATH}" + fi + # Let subsequent steps know where to find the (stripped) bin + echo ::set-output name=BIN_PATH::${BIN_PATH} + echo ::set-output name=BIN_NAME::${BIN_NAME} + - name: Create tarball + id: package + shell: bash + run: | + PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; + PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }} + PKG_NAME=${PKG_BASENAME}${PKG_suffix} + echo ::set-output name=PKG_NAME::${PKG_NAME} + PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package" + ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" + mkdir -p "${ARCHIVE_DIR}" + mkdir -p "${ARCHIVE_DIR}/autocomplete" + # Binary + cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR" + # base compressed package + pushd "${PKG_STAGING}/" >/dev/null + case ${{ matrix.job.target }} in + *-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;; + *) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;; + esac; + popd >/dev/null + # Let subsequent steps know where to find the compressed package + echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}" + - name: "Artifact upload: tarball" + uses: actions/upload-artifact@master + with: + name: ${{ steps.package.outputs.PKG_NAME }} + path: ${{ steps.package.outputs.PKG_PATH }} - - name: Extract version - id: extract-version - run: | - printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}" - # - uses: mislav/bump-homebrew-formula-action@v1 - # with: - # formula-path: ${{env.PROJECT_NAME}}.rb - # homebrew-tap: ${{ env.BREW_TAP }} - # download-url: "https://github.com/${{ env.REPO_NAME }}/releases/download/${{ steps.extract-version.outputs.tag-name }}/${{env.PROJECT_NAME}}-${{ steps.extract-version.outputs.tag-name }}-x86_64-macos.tar.xz" - # commit-message: updating formula for ${{ env.PROJECT_NAME }} - # env: - # COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} - # - # you can use this initial file in your homebrew-tap if you don't have an initial formula: - # .rb - # - # class < Formula - # desc "A test formula" - # homepage "http://www.example.com" - # url "-----" - # version "-----" - # sha256 "-----" + - name: Check for release + id: is-release + shell: bash + run: | + unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi + echo ::set-output name=IS_RELEASE::${IS_RELEASE} + - name: Publish archives and packages + uses: softprops/action-gh-release@v1 + if: steps.is-release.outputs.IS_RELEASE + with: + files: | + ${{ steps.package.outputs.PKG_PATH }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # def install - # bin.install "" - # end - # end \ No newline at end of file