support minify #87
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
permissions: | |
contents: write | |
on: [push] | |
defaults: | |
run: | |
shell: bash --noprofile --norc -CeEuo pipefail {0} | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: taiki-e/create-gh-release-action@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
upload-assets: | |
needs: create-release | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
RUSTFLAGS: -C target-feature=+crt-static | |
- target: x86_64-pc-windows-gnu | |
os: windows-latest | |
- target: arm64ec-pc-windows-msvc | |
os: windows-latest | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
rustflags: "-A warnings" | |
toolchain: "nightly" | |
- name: Setup musl aarch64 | |
if: startsWith(matrix.target, 'aarch64-unknown-linux') | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y \ | |
curl \ | |
libc6-arm64-cross \ | |
libc6-dev-arm64-cross \ | |
crossbuild-essential-arm64 \ | |
clang \ | |
qemu-system-arm \ | |
qemu-efi-aarch64 \ | |
qemu-utils \ | |
qemu-user | |
curl --retry 5 https://musl.cc/aarch64-linux-musl-cross.tgz | tar xzf - | |
sudo mv aarch64-linux-musl-cross /musl | |
echo "CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc" >> $GITHUB_ENV | |
echo "CXX_aarch64_unknown_linux_musl=aarch64-linux-musl-g++" >> $GITHUB_ENV | |
echo "AR_aarch64_unknown_linux_musl=aarch64-linux-musl-ar" >> $GITHUB_ENV | |
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc" >> $GITHUB_ENV | |
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64" >> $GITHUB_ENV | |
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV | |
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV | |
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-aarch64" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib" >> $GITHUB_ENV | |
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib/ld-linux-aarch64.so.1 | |
mkdir -p ~/.cargo/ | |
echo "[target.aarch64-unknown-linux-musl]" >> ~/.cargo/config.toml | |
echo 'rustflags = ["-C", "link-self-contained=yes","-C", "linker=rust-lld"]' >> ~/.cargo/config.toml | |
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml | |
echo 'rustflags = ["-C", "linker=aarch64-linux-gnu-gcc"]' >> ~/.cargo/config.toml | |
echo "/musl/bin" >> $GITHUB_PATH | |
- uses: taiki-e/upload-rust-binary-action@v1 | |
with: | |
dry-run: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
bin: ansi2 | |
target: ${{ matrix.target }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# ref: refs/tags/dummy | |
ref: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || 'refs/tags/dummy' }} | |
features: cli | |
env: | |
RUSTFLAGS: ${{ matrix.RUSTFLAGS }} | |
- name: Get target name for artifact | |
id: artifact-target | |
run: | | |
target="${{ matrix.target }}" | |
if [[ -z "${target}" ]]; then | |
host=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2) | |
printf '%s\n' "artifact-target=${host}" >>"${GITHUB_OUTPUT}" | |
elif [[ "${{ matrix.build-tool }}" == 'cargo-zigbuild' ]]; then | |
printf '%s\n' "artifact-target=${target%%.*}" >>"${GITHUB_OUTPUT}" | |
else | |
printf '%s\n' "artifact-target=${target}" >>"${GITHUB_OUTPUT}" | |
fi | |
# For debugging | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ansi2-${{ steps.artifact-target.outputs.artifact-target }} | |
path: ansi2-${{ steps.artifact-target.outputs.artifact-target }}.* |