mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
215 lines
6.6 KiB
YAML
215 lines
6.6 KiB
YAML
name: Build and integration tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
tags: [ 'v*' ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and Test
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
output: cargo-binstall
|
|
use-cross: false
|
|
test: true
|
|
debug_build_args: --no-default-features --features rustls,pkg-config
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
output: cargo-binstall
|
|
use-cross: false
|
|
test: true
|
|
debug_build_args: --no-default-features --features rustls
|
|
- target: aarch64-apple-darwin
|
|
os: macos-latest
|
|
output: cargo-binstall
|
|
use-cross: false
|
|
test: false
|
|
debug_build_args: --no-default-features --features rustls
|
|
- target: x86_64-pc-windows-msvc
|
|
os: windows-latest
|
|
output: cargo-binstall.exe
|
|
use-cross: false
|
|
test: false
|
|
debug_build_args: --no-default-features --features native-tls
|
|
release_build_args: --no-default-features --features static,zlib-ng,native-tls
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
output: cargo-binstall
|
|
use-cross: false
|
|
test: true
|
|
debug_build_args: --no-default-features --features rustls
|
|
- target: armv7-unknown-linux-musleabihf
|
|
os: ubuntu-20.04
|
|
output: cargo-binstall
|
|
use-cross: true
|
|
test: false
|
|
debug_build_args: --no-default-features --features rustls
|
|
- target: armv7-unknown-linux-gnueabihf
|
|
os: ubuntu-20.04
|
|
output: cargo-binstall
|
|
use-cross: true
|
|
test: false
|
|
debug_build_args: --no-default-features --features rustls
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
output: cargo-binstall
|
|
use-cross: true
|
|
test: false
|
|
debug_build_args: --no-default-features --features rustls
|
|
- target: aarch64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
output: cargo-binstall
|
|
use-cross: true
|
|
test: false
|
|
debug_build_args: --no-default-features --features rustls
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Configure toolchain
|
|
run: |
|
|
rustup toolchain install --profile minimal --no-self-update nightly
|
|
rustup default nightly
|
|
|
|
- name: Install cross
|
|
if: matrix.use-cross
|
|
uses: taiki-e/install-action@v1
|
|
with:
|
|
tool: cross
|
|
|
|
- name: Install host target
|
|
if: "!matrix.use-cross"
|
|
run: rustup target add ${{ matrix.target }}
|
|
|
|
- name: Select compile settings
|
|
shell: bash
|
|
run: |
|
|
jq \
|
|
--arg ref '${{ github.ref }}' \
|
|
--argjson matrix '${{ toJSON(matrix) }}' \
|
|
-nrf ci-scripts/compile-settings.jq \
|
|
| tee -a $GITHUB_ENV
|
|
|
|
- name: Configure caching
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
target/
|
|
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.COUTPUT }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
${{ runner.os }}-cargo-${{ matrix.target }}-
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Install musl-tools
|
|
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
|
|
run: sudo apt-get install -y musl-tools
|
|
|
|
- name: Install deps
|
|
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' && !startsWith(github.ref, 'refs/tags/v') }}
|
|
run: sudo ./ci-scripts/install-deps.sh
|
|
|
|
- name: Build
|
|
run: ${{ env.CTOOL }} build ${{ env.CARGS }}
|
|
|
|
- name: Copy and rename utility
|
|
run: cp target/${{ matrix.target }}/${{ env.COUTPUT }}/${{ matrix.output }} ${{ matrix.output }}
|
|
|
|
- name: Test (Unix)
|
|
if: ${{ matrix.test && matrix.os != 'windows-latest' }}
|
|
run: ./ci-scripts/run_tests_unix.sh ${{ matrix.output }}
|
|
|
|
- name: Test (Windows)
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
run: |
|
|
./${{ matrix.output }} binstall --no-confirm cargo-binstall
|
|
cargo binstall --help
|
|
./${{ matrix.output }} binstall --manifest-path . --no-confirm cargo-binstall
|
|
cargo binstall --help
|
|
|
|
- name: Upload output
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
retention-days: 1
|
|
name: "${{ matrix.target }}.${{ matrix.output }}"
|
|
path: "${{ matrix.output }}"
|
|
|
|
release:
|
|
name: Package and release
|
|
needs: build
|
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Get outputs
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: outputs/
|
|
|
|
- name: Create archives
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
for o in outputs/*; do
|
|
pushd "$o"
|
|
|
|
cp ../../LICENSE.txt ../../README.md .
|
|
|
|
target=$(basename "$o" | cut -d. -f1)
|
|
if grep -qE '(apple|windows)' <<< "$target"; then
|
|
zip "../cargo-binstall-${target}.zip" *
|
|
else
|
|
tar cvf "../cargo-binstall-${target}.tgz" *
|
|
fi
|
|
|
|
popd
|
|
done
|
|
|
|
- name: Extract release notes
|
|
id: notes
|
|
shell: bash
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_REPO: ${{ github.repository }}
|
|
release_commit: ${{ github.event.head_commit.message }}
|
|
run: |
|
|
set -euxo pipefail
|
|
release_pr=$(head -n1 <<< "${release_commit:-}" | jq -Rr 'split("[()]"; "")[1] // ""')
|
|
if [[ -z "$release_pr" ]]; then
|
|
echo "::set-output name=notes_json::null"
|
|
exit
|
|
fi
|
|
|
|
gh \
|
|
pr --repo "$GITHUB_REPO" \
|
|
view "$release_pr" \
|
|
--json body \
|
|
--jq '"::set-output name=notes_json::\((.body | split("### Release notes")[1] // "") | tojson)"'
|
|
|
|
- name: Publish release
|
|
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
name: ${{ github.ref }}
|
|
body: ${{ fromJSON(steps.notes.outputs.notes_json) }}
|
|
append_body: true
|
|
files: |
|
|
outputs/cargo-binstall-*.zip
|
|
outputs/cargo-binstall-*.tgz
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|