2020-07-03 11:38:52 -04:00
|
|
|
name: Publish
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
publish:
|
2020-07-03 11:58:27 -04:00
|
|
|
name: ${{ matrix.target }}
|
2020-07-03 11:38:52 -04:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: x86_64-unknown-linux-gnu
|
2021-02-28 23:41:21 -05:00
|
|
|
use-cross: false
|
2020-07-03 11:38:52 -04:00
|
|
|
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: x86_64-unknown-linux-musl
|
2021-02-28 23:41:21 -05:00
|
|
|
use-cross: false
|
|
|
|
|
|
|
|
- os: ubuntu-latest
|
|
|
|
target: arm-unknown-linux-gnueabihf
|
|
|
|
use-cross: true
|
2020-07-03 11:38:52 -04:00
|
|
|
|
2023-08-20 12:42:08 -04:00
|
|
|
- os: windows-latest
|
|
|
|
target: x86_64-pc-windows-gnu
|
|
|
|
use-cross: false
|
|
|
|
|
|
|
|
- os: windows-latest
|
|
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
use-cross: false
|
2020-07-03 11:38:52 -04:00
|
|
|
|
|
|
|
- os: macos-latest
|
|
|
|
target: x86_64-apple-darwin
|
2021-02-28 23:41:21 -05:00
|
|
|
use-cross: false
|
2020-07-03 11:38:52 -04:00
|
|
|
|
2021-03-04 23:36:44 -05:00
|
|
|
- os: macos-latest
|
|
|
|
target: aarch64-apple-darwin
|
|
|
|
use-cross: false
|
|
|
|
|
2023-05-17 14:54:28 -04:00
|
|
|
- os: ubuntu-latest
|
|
|
|
target: aarch64-unknown-linux-musl
|
|
|
|
use-cross: true
|
|
|
|
|
2023-08-20 12:38:02 -04:00
|
|
|
- os: ubuntu-latest
|
|
|
|
target: armv7-unknown-linux-gnueabihf
|
|
|
|
use-cross: true
|
|
|
|
|
2020-07-03 11:38:52 -04:00
|
|
|
steps:
|
2020-07-03 11:40:54 -04:00
|
|
|
- name: Checkout repository
|
2023-09-23 21:57:51 -06:00
|
|
|
uses: actions/checkout@v4
|
2020-07-03 11:40:54 -04:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
- name: Set the version
|
2023-10-20 18:02:45 -06:00
|
|
|
shell: bash
|
|
|
|
if: env.SD_VERSION == ''
|
|
|
|
run: |
|
|
|
|
echo "SD_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
|
|
|
|
echo "version is: ${{ env.SD_VERSION }}"
|
2020-07-03 11:40:54 -04:00
|
|
|
|
|
|
|
- name: Install Rust
|
2023-10-20 18:02:45 -06:00
|
|
|
uses: dtolnay/rust-toolchain@stable
|
2020-07-03 11:40:54 -04:00
|
|
|
with:
|
2023-10-20 18:02:45 -06:00
|
|
|
targets: ${{ matrix.target }}
|
|
|
|
|
2023-10-21 20:06:52 -06:00
|
|
|
- name: Setup native compilation
|
|
|
|
if: ${{ matrix.use-cross == false }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "CARGO=cargo" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Setup cross compilation
|
2023-10-20 18:02:45 -06:00
|
|
|
if: ${{ matrix.use-cross == true }}
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
dir="$RUNNER_TEMP/cross-download"
|
|
|
|
mkdir "$dir"
|
|
|
|
echo "$dir" >> $GITHUB_PATH
|
|
|
|
cd "$dir"
|
|
|
|
curl -LO "https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-musl.tar.gz"
|
|
|
|
tar xf cross-x86_64-unknown-linux-musl.tar.gz
|
|
|
|
echo "CARGO=cross" >> $GITHUB_ENV
|
2023-10-21 20:06:52 -06:00
|
|
|
echo "RUSTFLAGS=--cfg sd_cross_compile" >> $GITHUB_ENV
|
|
|
|
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
2020-07-03 11:38:52 -04:00
|
|
|
|
|
|
|
- name: Build
|
2023-10-21 20:06:52 -06:00
|
|
|
shell: bash
|
2023-10-20 18:02:45 -06:00
|
|
|
run: |
|
2023-10-21 20:06:52 -06:00
|
|
|
$CARGO --version
|
|
|
|
$CARGO build --release --locked --target ${{ matrix.target }}
|
2023-10-21 20:31:33 -06:00
|
|
|
# Handle windows being an oddity
|
|
|
|
if [ "${{ matrix.os }}" = "windows-latest" ]; then
|
|
|
|
echo "BIN_NAME=sd.exe" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "BIN_NAME=sd" >> $GITHUB_ENV
|
|
|
|
fi
|
2020-07-03 11:38:52 -04:00
|
|
|
|
2023-10-23 19:36:58 -06:00
|
|
|
- name: Setup archive
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
staging="sd-${{ env.SD_VERSION }}-${{ matrix.target }}"
|
|
|
|
mkdir -p "$staging"
|
|
|
|
|
2023-11-01 19:57:04 -06:00
|
|
|
cp -r {README.md,LICENSE,CHANGELOG.md,gen/*} "$staging"
|
2023-10-23 19:36:58 -06:00
|
|
|
if [ "${{ matrix.os }}" = "windows-latest" ]; then
|
|
|
|
cp "target/${{ matrix.target }}/release/sd.exe" "$staging/"
|
|
|
|
7z a "$staging.zip" "$staging"
|
|
|
|
echo "ASSET=$staging.zip" >> $GITHUB_ENV
|
|
|
|
else
|
2023-10-23 19:50:41 -06:00
|
|
|
cp "target/${{ matrix.target }}/release/sd" "$staging/"
|
2023-10-23 19:36:58 -06:00
|
|
|
tar czf "$staging.tar.gz" "$staging"
|
|
|
|
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
|
2020-07-03 11:38:52 -04:00
|
|
|
- name: Upload binaries to release
|
2023-08-21 19:09:34 -05:00
|
|
|
uses: svenstaro/upload-release-action@2.7.0
|
2020-07-03 11:38:52 -04:00
|
|
|
with:
|
|
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
2023-10-23 19:36:58 -06:00
|
|
|
file: ${{ env.ASSET }}
|
|
|
|
asset_name: ${{ env.ASSET }}
|
2020-07-03 11:38:52 -04:00
|
|
|
tag: ${{ github.ref }}
|