mirror of
https://github.com/ducaale/xh.git
synced 2025-05-05 15:32:50 +00:00
148 lines
4.7 KiB
YAML
148 lines
4.7 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags: [ v*.*.* ]
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ${{ matrix.job.os }}
|
|
timeout-minutes: 15
|
|
strategy:
|
|
matrix:
|
|
job:
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
flags: --features=native-tls
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
flags: --no-default-features --features=native-tls,online-tests # disables rustls
|
|
- target: x86_64-apple-darwin
|
|
os: macos-13
|
|
flags: --features=native-tls
|
|
- target: aarch64-apple-darwin
|
|
os: macos-14
|
|
flags: --features=native-tls
|
|
- target: x86_64-pc-windows-msvc
|
|
os: windows-latest
|
|
flags: --features=native-tls
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
use-cross: true
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
use-cross: true
|
|
flags: -- --test-threads=4
|
|
- target: arm-unknown-linux-gnueabihf
|
|
os: ubuntu-latest
|
|
use-cross: true
|
|
flags: -- --test-threads=4
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: 1.74.0 # minimum supported rust version
|
|
targets: ${{ matrix.job.target }}
|
|
|
|
- uses: ClementTsang/cargo-action@v0.0.6
|
|
with:
|
|
use-cross: ${{ !!matrix.job.use-cross }}
|
|
command: test
|
|
args: --target ${{ matrix.job.target }} ${{ matrix.job.flags }}
|
|
|
|
deploy:
|
|
name: Deploy
|
|
needs: [ test ]
|
|
runs-on: ${{ matrix.job.os }}
|
|
strategy:
|
|
matrix:
|
|
job:
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-musl
|
|
binutils: aarch64-linux-gnu
|
|
use-cross: true
|
|
- os: ubuntu-latest
|
|
target: arm-unknown-linux-gnueabihf
|
|
binutils: arm-linux-gnueabihf
|
|
use-cross: true
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-musl
|
|
use-cross: true
|
|
- os: macos-13
|
|
target: x86_64-apple-darwin
|
|
flags: --features=native-tls
|
|
- os: macos-14
|
|
target: aarch64-apple-darwin
|
|
flags: --features=native-tls
|
|
- os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
flags: --features=native-tls
|
|
rustflags: -C target-feature=+crt-static
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set RUSTFLAGS env variable
|
|
if: matrix.job.rustflags
|
|
shell: bash
|
|
run: echo "RUSTFLAGS=${{ matrix.job.rustflags }}" >> $GITHUB_ENV
|
|
|
|
- name: Build target
|
|
uses: ClementTsang/cargo-action@v0.0.6
|
|
with:
|
|
use-cross: ${{ !!matrix.job.use-cross }}
|
|
command: build
|
|
args: --release --target ${{ matrix.job.target }} ${{ matrix.job.flags }}
|
|
env:
|
|
CARGO_PROFILE_RELEASE_LTO: true
|
|
|
|
- name: Strip release binary (linux and macOS)
|
|
if: matrix.job.os != 'windows-latest'
|
|
run: |
|
|
if [ "${{ matrix.job.binutils }}" != "" ]; then
|
|
sudo apt -y install "binutils-${{ matrix.job.binutils }}"
|
|
"${{ matrix.job.binutils }}-strip" "target/${{ matrix.job.target }}/release/xh"
|
|
else
|
|
strip "target/${{ matrix.job.target }}/release/xh"
|
|
fi
|
|
|
|
- name: Package
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ matrix.job.os }}" = "windows-latest" ]; then
|
|
bin="target/${{ matrix.job.target }}/release/xh.exe"
|
|
else
|
|
bin="target/${{ matrix.job.target }}/release/xh"
|
|
fi
|
|
staging="xh-${{ github.ref_name }}-${{ matrix.job.target }}"
|
|
|
|
mkdir -p "$staging"/{doc,completions}
|
|
cp LICENSE README.md $bin $staging
|
|
cp CHANGELOG.md doc/xh.1 "$staging"/doc
|
|
cp completions/* "$staging"/completions
|
|
|
|
if [ "${{ matrix.job.os }}" = "windows-latest" ]; then
|
|
7z a "$staging.zip" $staging
|
|
elif [[ "${{ matrix.job.os }}" =~ "macos" ]]; then
|
|
gtar czvf "$staging.tar.gz" $staging
|
|
else
|
|
tar czvf "$staging.tar.gz" $staging
|
|
fi
|
|
|
|
- name: Package (debian)
|
|
if: matrix.job.target == 'x86_64-unknown-linux-musl'
|
|
shell: bash
|
|
run: |
|
|
cargo install --git https://github.com/blyxxyz/cargo-deb --locked --branch xh-patches cargo-deb
|
|
cargo deb --no-build --target ${{ matrix.job.target }}
|
|
cp "target/${{ matrix.job.target }}/debian"/*.deb ./
|
|
|
|
- name: Publish
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: 'xh*'
|
|
draft: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|