sd/.github/workflows/publish.yml

125 lines
3.4 KiB
YAML
Raw Normal View History

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
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
- 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
uses: actions/checkout@v4
2020-07-03 11:40:54 -04:00
with:
fetch-depth: 1
- name: Set the version
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
uses: dtolnay/rust-toolchain@stable
2020-07-03 11:40:54 -04:00
with:
targets: ${{ matrix.target }}
- name: Setup native compilation
if: ${{ matrix.use-cross == false }}
shell: bash
run: |
echo "CARGO=cargo" >> $GITHUB_ENV
- name: Setup cross compilation
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
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
shell: bash
run: |
$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
- name: Setup archive
shell: bash
run: |
staging="sd-${{ env.SD_VERSION }}-${{ matrix.target }}"
mkdir -p "$staging"
cp -r {README.md,LICENSE,CHANGELOG.md,gen/*} "$staging"
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/"
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
uses: svenstaro/upload-release-action@2.7.0
2020-07-03 11:38:52 -04:00
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
2020-07-03 11:38:52 -04:00
tag: ${{ github.ref }}