2021-06-01 02:47:22 +02:00
|
|
|
# The way this works is the following:
|
2020-03-15 21:54:37 +02:00
|
|
|
#
|
2021-06-01 02:47:22 +02:00
|
|
|
# The create-release job runs purely to initialize the GitHub release itself
|
|
|
|
# and to output upload_url for the following job.
|
|
|
|
#
|
|
|
|
# The build-release job runs only once create-release is finished. It gets the
|
|
|
|
# release upload URL from create-release job outputs, then builds the release
|
|
|
|
# executables for each supported platform and attaches them as release assets
|
|
|
|
# to the previously created release.
|
2020-03-15 21:54:37 +02:00
|
|
|
#
|
|
|
|
# The key here is that we create the release only once.
|
2021-06-01 02:47:22 +02:00
|
|
|
#
|
|
|
|
# Reference:
|
|
|
|
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
|
2020-03-15 21:54:37 +02:00
|
|
|
|
|
|
|
name: release
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
# Enable when testing release infrastructure on a branch.
|
|
|
|
# branches:
|
2021-06-01 02:47:22 +02:00
|
|
|
# - ag/work
|
2020-03-15 21:54:37 +02:00
|
|
|
tags:
|
2021-06-01 02:47:22 +02:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+"
|
2020-03-15 21:54:37 +02:00
|
|
|
jobs:
|
|
|
|
create-release:
|
|
|
|
name: create-release
|
2022-09-29 04:49:24 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2020-03-16 03:54:11 +02:00
|
|
|
# env:
|
2020-03-15 21:54:37 +02:00
|
|
|
# Set to force version number, e.g., when no tag exists.
|
|
|
|
# RG_VERSION: TEST-0.0.0
|
2021-06-01 02:47:22 +02:00
|
|
|
outputs:
|
|
|
|
upload_url: ${{ steps.release.outputs.upload_url }}
|
|
|
|
rg_version: ${{ env.RG_VERSION }}
|
2020-03-15 21:54:37 +02:00
|
|
|
steps:
|
|
|
|
- name: Get the release version from the tag
|
2021-06-01 02:47:22 +02:00
|
|
|
shell: bash
|
2020-03-15 21:54:37 +02:00
|
|
|
if: env.RG_VERSION == ''
|
|
|
|
run: |
|
|
|
|
# Apparently, this is the right way to get a tag name. Really?
|
|
|
|
#
|
|
|
|
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
|
2020-11-17 02:17:36 +02:00
|
|
|
echo "RG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
2020-03-15 21:54:37 +02:00
|
|
|
echo "version is: ${{ env.RG_VERSION }}"
|
|
|
|
- name: Create GitHub release
|
|
|
|
id: release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ env.RG_VERSION }}
|
2020-03-16 04:07:22 +02:00
|
|
|
release_name: ${{ env.RG_VERSION }}
|
2020-03-15 21:54:37 +02:00
|
|
|
|
|
|
|
build-release:
|
|
|
|
name: build-release
|
|
|
|
needs: ['create-release']
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
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`.
|
2021-06-01 02:47:22 +02:00
|
|
|
TARGET_FLAGS: ""
|
2020-03-15 21:54:37 +02:00
|
|
|
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
|
|
|
|
TARGET_DIR: ./target
|
|
|
|
# Emit backtraces on panics.
|
|
|
|
RUST_BACKTRACE: 1
|
|
|
|
# Build static releases with PCRE2.
|
|
|
|
PCRE2_SYS_STATIC: 1
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc]
|
|
|
|
include:
|
|
|
|
- build: linux
|
2022-09-29 04:49:24 +02:00
|
|
|
os: ubuntu-22.04
|
2020-03-15 21:54:37 +02:00
|
|
|
rust: nightly
|
|
|
|
target: x86_64-unknown-linux-musl
|
|
|
|
- build: linux-arm
|
2022-09-29 04:49:24 +02:00
|
|
|
os: ubuntu-22.04
|
2020-03-15 21:54:37 +02:00
|
|
|
rust: nightly
|
|
|
|
target: arm-unknown-linux-gnueabihf
|
|
|
|
- build: macos
|
2022-09-29 04:49:24 +02:00
|
|
|
os: macos-12
|
2020-03-15 21:54:37 +02:00
|
|
|
rust: nightly
|
|
|
|
target: x86_64-apple-darwin
|
|
|
|
- build: win-msvc
|
2022-09-29 04:49:24 +02:00
|
|
|
os: windows-2022
|
2020-03-15 21:54:37 +02:00
|
|
|
rust: nightly
|
|
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
- build: win-gnu
|
2022-09-29 04:49:24 +02:00
|
|
|
os: windows-2022
|
2020-03-15 21:54:37 +02:00
|
|
|
rust: nightly-x86_64-gnu
|
|
|
|
target: x86_64-pc-windows-gnu
|
|
|
|
- build: win32-msvc
|
2022-09-29 04:49:24 +02:00
|
|
|
os: windows-2022
|
2020-03-15 21:54:37 +02:00
|
|
|
rust: nightly
|
|
|
|
target: i686-pc-windows-msvc
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2020-03-30 23:09:41 +02:00
|
|
|
uses: actions/checkout@v2
|
2020-03-15 21:54:37 +02:00
|
|
|
|
|
|
|
- name: Install packages (Ubuntu)
|
2022-09-29 04:49:24 +02:00
|
|
|
if: matrix.os == 'ubuntu-22.04'
|
2020-03-15 21:54:37 +02:00
|
|
|
run: |
|
|
|
|
ci/ubuntu-install-packages
|
|
|
|
|
|
|
|
- name: Install packages (macOS)
|
2022-09-29 04:49:24 +02:00
|
|
|
if: matrix.os == 'macos-12'
|
2020-03-15 21:54:37 +02:00
|
|
|
run: |
|
|
|
|
ci/macos-install-packages
|
|
|
|
|
|
|
|
- name: Install Rust
|
2022-09-29 04:55:33 +02:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2020-03-15 21:54:37 +02:00
|
|
|
with:
|
|
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Use Cross
|
2021-06-01 02:47:22 +02:00
|
|
|
shell: bash
|
2020-03-15 21:54:37 +02:00
|
|
|
run: |
|
2020-11-09 14:25:41 +02:00
|
|
|
cargo install cross
|
2020-11-17 02:17:36 +02:00
|
|
|
echo "CARGO=cross" >> $GITHUB_ENV
|
|
|
|
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
|
|
|
|
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
2020-03-15 21:54:37 +02:00
|
|
|
|
|
|
|
- name: Show command used for Cargo
|
|
|
|
run: |
|
|
|
|
echo "cargo command is: ${{ env.CARGO }}"
|
|
|
|
echo "target flag is: ${{ env.TARGET_FLAGS }}"
|
|
|
|
echo "target dir is: ${{ env.TARGET_DIR }}"
|
|
|
|
|
|
|
|
- name: Build release binary
|
|
|
|
run: ${{ env.CARGO }} build --verbose --release --features pcre2 ${{ env.TARGET_FLAGS }}
|
|
|
|
|
|
|
|
- name: Strip release binary (linux and macos)
|
|
|
|
if: matrix.build == 'linux' || matrix.build == 'macos'
|
|
|
|
run: strip "target/${{ matrix.target }}/release/rg"
|
|
|
|
|
|
|
|
- name: Strip release binary (arm)
|
|
|
|
if: matrix.build == 'linux-arm'
|
|
|
|
run: |
|
|
|
|
docker run --rm -v \
|
|
|
|
"$PWD/target:/target:Z" \
|
|
|
|
rustembedded/cross:arm-unknown-linux-gnueabihf \
|
|
|
|
arm-linux-gnueabihf-strip \
|
|
|
|
/target/arm-unknown-linux-gnueabihf/release/rg
|
|
|
|
|
|
|
|
- name: Build archive
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
|
2021-06-01 02:47:22 +02:00
|
|
|
staging="ripgrep-${{ needs.create-release.outputs.rg_version }}-${{ matrix.target }}"
|
2020-03-15 21:54:37 +02:00
|
|
|
mkdir -p "$staging"/{complete,doc}
|
|
|
|
|
|
|
|
cp {README.md,COPYING,UNLICENSE,LICENSE-MIT} "$staging/"
|
|
|
|
cp {CHANGELOG.md,FAQ.md,GUIDE.md} "$staging/doc/"
|
|
|
|
cp "$outdir"/{rg.bash,rg.fish,_rg.ps1} "$staging/complete/"
|
|
|
|
cp complete/_rg "$staging/complete/"
|
|
|
|
|
2022-09-29 04:49:24 +02:00
|
|
|
if [ "${{ matrix.os }}" = "windows-2022" ]; then
|
2020-03-15 21:54:37 +02:00
|
|
|
cp "target/${{ matrix.target }}/release/rg.exe" "$staging/"
|
|
|
|
7z a "$staging.zip" "$staging"
|
2020-11-17 02:17:36 +02:00
|
|
|
echo "ASSET=$staging.zip" >> $GITHUB_ENV
|
2020-03-15 21:54:37 +02:00
|
|
|
else
|
|
|
|
# The man page is only generated on Unix systems. ¯\_(ツ)_/¯
|
|
|
|
cp "$outdir"/rg.1 "$staging/doc/"
|
|
|
|
cp "target/${{ matrix.target }}/release/rg" "$staging/"
|
|
|
|
tar czf "$staging.tar.gz" "$staging"
|
2020-11-17 02:17:36 +02:00
|
|
|
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
|
2020-03-15 21:54:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Upload release archive
|
|
|
|
uses: actions/upload-release-asset@v1.0.1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2021-06-01 02:47:22 +02:00
|
|
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
2020-03-15 21:54:37 +02:00
|
|
|
asset_path: ${{ env.ASSET }}
|
|
|
|
asset_name: ${{ env.ASSET }}
|
|
|
|
asset_content_type: application/octet-stream
|