name: CICD # spell-checker:ignore CICD MSVC MacOS SHAs clippy esac gnueabihf mkdir musl rustfmt softprops toolchain env: PROJECT_NAME: lsd on: [push, pull_request] jobs: style: name: Style runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - uses: actions/checkout@v1 - name: Install `rust` toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable override: true profile: minimal # minimal component installation (ie, no documentation) components: rustfmt, clippy - name: "`fmt` testing" uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check - name: "`clippy` testing" uses: actions-rs/cargo@v1 with: command: clippy args: -- -D warnings build_linux: name: Build/linux runs-on: ubuntu-latest strategy: fail-fast: false matrix: target: - arm-unknown-linux-gnueabihf - i686-unknown-linux-gnu - i686-unknown-linux-musl # - x86_64-apple-darwin - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl # - i686-pc-windows-gnu # - x86_64-pc-windows-gnu env: EXE_suffix: "" steps: - uses: actions/checkout@v1 - name: Setup target-specific options id: cargo_options shell: bash run: | # test only binary for arm-type targets unset TEST_OPTIONS; case ${{ matrix.target }} in arm-*) TEST_OPTIONS="--bin ${PROJECT_NAME}";; esac; echo ::set-output name=TEST_OPTIONS::${TEST_OPTIONS} - name: Parse branch info id: branch_info shell: bash run: | # ref: REF_NAME=${GITHUB_REF#refs/*/} unset REF_BRANCH; case ${GITHUB_REF} in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/};; esac; unset REF_TAG; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/};; esac; REF_SHAS=${GITHUB_SHA:0:8} PKG_NAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.target }}${EXE_suffix} echo ::set-output name=REF_NAME::${REF_NAME} echo ::set-output name=REF_BRANCH::${REF_BRANCH} echo ::set-output name=REF_TAG::${REF_TAG} echo ::set-output name=REF_SHAS::${REF_SHAS} echo ::set-output name=PKG_NAME::${PKG_NAME} - name: Create all needed build/work directories shell: bash run: mkdir -p 'package' - name: Install `rust` toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} override: true profile: minimal # minimal component installation (ie, no documentation) - name: Build uses: actions-rs/cargo@v1 with: use-cross: true command: build args: --release --target=${{ matrix.target }} - name: Test uses: actions-rs/cargo@v1 with: use-cross: true command: test args: --target=${{ matrix.target }} ${{ steps.cargo_options.outputs.TEST_OPTIONS}} - name: Archive executable artifacts uses: actions/upload-artifact@master with: name: ${{ env.PROJECT_NAME }}-${{ matrix.target }} path: target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}${{ env.EXE_suffix }} - name: Package shell: bash run: cp 'target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}${{ env.EXE_suffix }}' 'package/${{ steps.branch_info.outputs.PKG_NAME }}' - name: Publish uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') with: files: package/${{ steps.branch_info.outputs.PKG_NAME }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build_mac: name: Build/mac runs-on: macos-latest strategy: fail-fast: false matrix: target: - x86_64-apple-darwin # - x86_64-unknown-linux-gnu # - x86_64-unknown-linux-musl # - i686-pc-windows-gnu # - x86_64-pc-windows-gnu env: EXE_suffix: "" steps: - uses: actions/checkout@v1 - name: Parse branch info id: branch_info shell: bash run: | # ref: REF_NAME=${GITHUB_REF#refs/*/} unset REF_BRANCH; case ${GITHUB_REF} in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/};; esac; unset REF_TAG; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/};; esac; REF_SHAS=${GITHUB_SHA:0:8} PKG_NAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.target }}${EXE_suffix} echo ::set-output name=REF_NAME::${REF_NAME} echo ::set-output name=REF_BRANCH::${REF_BRANCH} echo ::set-output name=REF_TAG::${REF_TAG} echo ::set-output name=REF_SHAS::${REF_SHAS} echo ::set-output name=PKG_NAME::${PKG_NAME} - name: Create all needed build/work directories shell: bash run: mkdir -p 'package' - name: Install `rust` toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} override: true profile: minimal # minimal component installation (ie, no documentation) - name: Build uses: actions-rs/cargo@v1 with: use-cross: true command: build args: --release --target=${{ matrix.target }} - name: Test uses: actions-rs/cargo@v1 with: use-cross: true command: test args: --target=${{ matrix.target }} - name: Archive executable artifacts uses: actions/upload-artifact@master with: name: ${{ env.PROJECT_NAME }}-${{ matrix.target }} path: target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}${{ env.EXE_suffix }} - name: Package shell: bash run: cp 'target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}${{ env.EXE_suffix }}' 'package/${{ steps.branch_info.outputs.PKG_NAME }}' - name: Publish uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') with: files: package/${{ steps.branch_info.outputs.PKG_NAME }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build_windows: name: Build/windows runs-on: windows-latest strategy: fail-fast: false matrix: target: # - i686-pc-windows-gnu - i686-pc-windows-msvc # - x86_64-pc-windows-gnu - x86_64-pc-windows-msvc env: EXE_suffix: .exe steps: - uses: actions/checkout@v1 - name: Parse branch info id: branch_info shell: bash run: | # ref: REF_NAME=${GITHUB_REF#refs/*/} unset REF_BRANCH; case ${GITHUB_REF} in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/};; esac; unset REF_TAG; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/};; esac; REF_SHAS=${GITHUB_SHA:0:8} PKG_NAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.target }}${EXE_suffix} echo ::set-output name=REF_NAME::${REF_NAME} echo ::set-output name=REF_BRANCH::${REF_BRANCH} echo ::set-output name=REF_TAG::${REF_TAG} echo ::set-output name=REF_SHAS::${REF_SHAS} echo ::set-output name=PKG_NAME::${PKG_NAME} - name: Create all needed build/work directories shell: bash run: mkdir -p 'package' - name: Install `rust` toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} override: true profile: minimal # minimal component installation (ie, no documentation) - name: Build uses: actions-rs/cargo@v1 with: use-cross: true command: build args: --release --target=${{ matrix.target }} - name: Test uses: actions-rs/cargo@v1 with: use-cross: true command: test args: --target=${{ matrix.target }} - name: Archive executable artifacts uses: actions/upload-artifact@master with: name: ${{ env.PROJECT_NAME }}-${{ matrix.target }} path: target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}${{ env.EXE_suffix }} - name: Package shell: bash run: cp 'target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}${{ env.EXE_suffix }}' 'package/${{ steps.branch_info.outputs.PKG_NAME }}' - name: Publish uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') with: files: package/${{ steps.branch_info.outputs.PKG_NAME }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}