-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.* | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
|
||
jobs: | ||
release: | ||
name: Release - ${{ matrix.platform.os_name }} | ||
if: startsWith( github.ref, 'refs/tags/v' ) || github.ref == 'refs/tags/test-release' | ||
strategy: | ||
matrix: | ||
platform: | ||
- os_name: FreeBSD-x86_64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-freebsd | ||
bin: prqlite | ||
name: prqlite-FreeBSD-x86_64.tar.gz | ||
cross: true | ||
cargo_command: ./cross | ||
|
||
- os_name: Linux-x86_64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-musl | ||
bin: prqlite | ||
name: prqlite-Linux-x86_64-musl.tar.gz | ||
cross: false | ||
cargo_command: cargo | ||
|
||
- os_name: Windows-aarch64 | ||
os: windows-latest | ||
target: aarch64-pc-windows-msvc | ||
bin: prqlite.exe | ||
name: prqlite-Windows-aarch64.zip | ||
cross: false | ||
cargo_command: cargo | ||
|
||
- os_name: macOS-x86_64 | ||
os: macOS-latest | ||
target: x86_64-apple-darwin | ||
bin: prqlite | ||
name: prqlite-Darwin-x86_64.tar.gz | ||
cross: false | ||
cargo_command: cargo | ||
|
||
runs-on: ${{ matrix.platform.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install toolchain if not cross-compiling | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.platform.target }} | ||
if: ${{ !matrix.platform.cross }} | ||
- name: Install musl-tools on Linux | ||
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools | ||
if: contains(matrix.platform.os, 'ubuntu') && !matrix.platform.cross | ||
- name: Install cross if cross-compiling (*nix) | ||
id: cross-nix | ||
shell: bash | ||
run: | | ||
set -e | ||
export TARGET="$HOME/bin" | ||
mkdir -p "$TARGET" | ||
./bootstrap/bootstrap-prqlite.sh | ||
"$HOME/bin/prqlite" --project cross-rs/cross --matching musl --in . | ||
if: matrix.platform.cross && !contains(matrix.platform.os, 'windows') | ||
- name: Install cross if cross-compiling (Windows) | ||
id: cross-windows | ||
shell: powershell | ||
run: | | ||
.\bootstrap\bootstrap-prqlite.ps1 | ||
.\prqlite --project cross-rs/cross --in . | ||
if: matrix.platform.cross && contains(matrix.platform.os, 'windows') | ||
- name: Build binary (*nix) | ||
shell: bash | ||
run: | | ||
${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} | ||
if: ${{ !contains(matrix.platform.os, 'windows') }} | ||
- name: Build binary (Windows) | ||
# We have to use the platform's native shell. If we use bash on | ||
# Windows then OpenSSL complains that the Perl it finds doesn't use | ||
# the platform's native paths and refuses to build. | ||
shell: powershell | ||
run: | | ||
& ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} | ||
if: contains(matrix.platform.os, 'windows') | ||
- name: Strip binary | ||
shell: bash | ||
run: | | ||
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | ||
# strip doesn't work with cross-arch binaries on Linux or Windows. | ||
if: ${{ !(matrix.platform.cross || matrix.platform.target == 'aarch64-pc-windows-msvc') }} | ||
- name: Package as archive | ||
shell: bash | ||
run: | | ||
cd target/${{ matrix.platform.target }}/release | ||
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | ||
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | ||
else | ||
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | ||
fi | ||
cd - | ||
- name: Publish release artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: prqlite-${{ matrix.platform.os_name }} | ||
path: "prqlite*" | ||
if: github.ref == 'refs/tags/test-release' | ||
- name: Publish GitHub release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
files: "prqlite*" | ||
body_path: Changes.md | ||
if: startsWith( github.ref, 'refs/tags/v' ) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Testing | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: cargo test --verbose |