121 lines
3.6 KiB
YAML
121 lines
3.6 KiB
YAML
# From https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml
|
|
# Which is also via https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
|
|
# ...both of which are very good.
|
|
#
|
|
# I'm sure I don't need half the stuff I have in here (around cargo
|
|
# customization and whatnot) but.
|
|
#
|
|
name: release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
tags:
|
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
|
|
|
jobs:
|
|
create_release:
|
|
name: Create release
|
|
runs-on: ubuntu-22.04
|
|
|
|
outputs:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
|
|
steps:
|
|
- name: Create GitHub release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: Release ${{ github.ref }}
|
|
draft: true
|
|
|
|
release_assets:
|
|
name: Release assets
|
|
needs: ['create_release'] # We need to know the upload URL
|
|
runs-on: ${{ matrix.os }} # We run many different builds
|
|
env:
|
|
# For some builds, we use cross to test on 32-bit and big-endian
|
|
# systems.
|
|
CARGO: cargo
|
|
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
|
|
TARGET_FLAGS: ""
|
|
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
|
|
TARGET_DIR: ./target
|
|
# Emit backtraces on panics.
|
|
RUST_BACKTRACE: 1
|
|
|
|
strategy:
|
|
matrix:
|
|
build: ['linux', 'macos', 'arm-macos', 'windows']
|
|
include:
|
|
- build: linux
|
|
os: ubuntu-22.04
|
|
target: x86_64-unknown-linux-musl
|
|
|
|
- build: macos
|
|
os: macos-12
|
|
target: x86_64-apple-darwin
|
|
|
|
- build: arm-macos
|
|
os: macos-12
|
|
target: aarch64-apple-darwin
|
|
|
|
- build: windows
|
|
os: windows-2022
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
target: ${{ matrix.target }}
|
|
|
|
- name: Use Cross
|
|
shell: bash
|
|
run: |
|
|
cargo install cross
|
|
echo "CARGO=cross" >> $GITHUB_ENV
|
|
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
|
|
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
|
|
|
- name: Build release binary
|
|
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
|
|
|
|
- name: Strip release binary (linux and macos)
|
|
if: matrix.build == 'linux' || matrix.build == 'macos' || matrix.build == 'arm-macos'
|
|
run: |
|
|
strip "target/${{ matrix.target }}/release/fwd"
|
|
strip "target/${{ matrix.target }}/release/fwd-browse"
|
|
|
|
- name: Build archive
|
|
shell: bash
|
|
run: |
|
|
staging="fwd-${{ matrix.target }}"
|
|
mkdir -p "$staging"
|
|
|
|
if [ "${{ matrix.os }}" = "windows-2022" ]; then
|
|
cp "target/${{ matrix.target }}/release/fwd.exe" "$staging/"
|
|
7z a "$staging.zip" "$staging"
|
|
echo "ASSET=$staging.zip" >> $GITHUB_ENV
|
|
else
|
|
cp "target/${{ matrix.target }}/release/fwd" "$staging/"
|
|
cp "target/${{ matrix.target }}/release/fwd-browse" "$staging/"
|
|
tar czf "$staging.tar.gz" "$staging"
|
|
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Upload release archive
|
|
uses: actions/upload-release-asset@v1.0.2
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
|
asset_name: ${{ env.ASSET }}
|
|
asset_path: ${{ env.ASSET }}
|
|
asset_content_type: application/octet-stream
|