diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b8e474..94dcdb4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,88 @@ jobs: path: tests/test-results.json - run: ./tests/print-test-results.sh tests/test-results.json + build: + name: build ${{ matrix.binary || 'findutils' }} ${{ matrix.target }} + runs-on: ${{ matrix.os }} + container: ${{ fromJson(matrix.container || '{"image":null}') }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + target: x86_64-unknown-linux-musl + - os: ubuntu-20.04 + target: aarch64-unknown-linux-musl + - os: ubuntu-20.04 + target: armv7-unknown-linux-musleabi + container: '{"image": "messense/rust-musl-cross:armv7-musleabi"}' + - os: ubuntu-20.04 + target: i686-unknown-linux-musl + container: '{"image": "messense/rust-musl-cross:i686-musl"}' + - os: macOS-11 + target: x86_64-apple-darwin + macosx_deployment_target: 10.13 + developer_dir: /Applications/Xcode_11.7.app + sdkroot: /Applications/Xcode_11.7.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk + - os: macos-14 + target: aarch64-apple-darwin + macosx_deployment_target: 11.0 + - os: windows-2019 + target: x86_64-pc-windows-msvc + rustflags: -Ctarget-feature=+crt-static + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install rust + uses: ./.github/actions/rust-toolchain + with: + toolchain: ${{ matrix.target == 'aarch64-apple-darwin' && 'beta' || 'stable' }} + target: ${{ matrix.target }} + if: ${{ !matrix.container }} + + - name: Install musl-tools (x86_64) + run: sudo apt-get install musl-tools + if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} + + - name: Install musl-tools (arm64) + run: | + set -x + sed 's/mirror+file:\/etc\/apt\/apt-mirrors\.txt/[arch=arm64] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/ports.list + sudo dpkg --add-architecture arm64 + sudo apt-get update || true + sudo apt-get install musl-dev:arm64 binutils-multiarch gcc-10-aarch64-linux-gnu libc6-dev-arm64-cross + apt-get download musl-tools:arm64 + sudo dpkg-deb -x musl-tools_*_arm64.deb / + sed 2iREALGCC=aarch64-linux-gnu-gcc-10 /usr/bin/musl-gcc | sudo tee /usr/bin/aarch64-linux-musl-gcc > /dev/null + sudo chmod +x /usr/bin/aarch64-linux-musl-gcc + if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }} + + - name: Build + run: cargo build --locked --release --bin ${{ matrix.binary || 'findutils' }} --target ${{ matrix.target }} --features=openssl/vendored ${{ matrix.extra_args }} + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }} + DEVELOPER_DIR: ${{ matrix.developer_dir }} + SDKROOT: ${{ matrix.sdkroot }} + RUSTFLAGS: ${{ matrix.rustflags }} + + # Workaround for the lack of substring() function in github actions expressions. + - name: Id + id: id + shell: bash + run: echo "id=${ID#refs/tags/}" >> $GITHUB_OUTPUT + env: + ID: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.sha }} + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.binary || 'findutils' }}-${{ steps.id.outputs.id }}-${{ matrix.target }} + path: target/${{ matrix.target }}/release/${{ matrix.binary || 'findutils' }}${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }} + if-no-files-found: error + coverage: name: Code Coverage runs-on: ${{ matrix.job.os }} @@ -152,3 +234,52 @@ jobs: name: codecov-umbrella fail_ci_if_error: false + + + release: + name: release + runs-on: ubuntu-latest + needs: [build, clippy, check, test] + if: ${{ startsWith(github.ref, 'refs/tags/') }} + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Check versions + run: | + tag_name=${GITHUB_REF#refs/tags/} + v=$(grep -m 1 "^version" Cargo.toml|sed -e "s|version = \"\(.*\)\"|\1|") + if ! echo $tag_name|grep -q $v; then + echo "Mistmatch of the version:" + echo "Cargo.toml says $v while the tag is $tag_name" + exit 2 + fi + + - name: Get artifacts + uses: actions/download-artifact@v4 + + - name: Create release assets + run: | + for d in findutils-*; do + chmod +x "$d/findutils"* + cp README.md LICENSE "$d/" + tar -zcvf "$d.tar.gz" "$d" + echo -n "$(shasum -ba 256 "$d.tar.gz" | cut -d " " -f 1)" > "$d.tar.gz.sha256" + if [[ $d =~ (findutils-)(.*)?(x86_64-pc-windows)(.*)? ]]; then + zip -r "$d.zip" "$d" + echo -n "$(shasum -ba 256 "$d.zip" | cut -d " " -f 1)" > "$d.zip.sha256" + fi + done + + - name: Create release + run: | + sudo apt-get update && sudo apt-get install -y hub + tag_name=${GITHUB_REF#refs/tags/} + for f in findutils-*.tar.gz* findutils-*.zip*; do + if [[ -f "$f" ]]; then + files="$files -a $f"; + fi + done + hub release create -m $tag_name $tag_name $files + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}