-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
1 changed file
with
157 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,157 @@ | ||
name: release | ||
on: | ||
release: | ||
types: | ||
- edited | ||
- published | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
prepare: | ||
name: Build release binary | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag_name: ${{ steps.get_release.outputs.tag_name }} | ||
upload_url: ${{ steps.get_release.outputs.upload_url }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get release | ||
id: get_release | ||
uses: bruceadams/get-release@v1.2.2 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
linux: | ||
runs-on: ubuntu-latest | ||
needs: prepare | ||
strategy: | ||
matrix: | ||
target: | ||
- x86_64-unknown-linux-gnu | ||
- x86_64-unknown-linux-musl | ||
- arm-unknown-linux-gnueabihf | ||
- arm-unknown-linux-musleabi | ||
- arm-unknown-linux-musleabihf | ||
- aarch64-unknown-linux-gnu | ||
- mips-unknown-linux-musl | ||
- mipsel-unknown-linux-musl | ||
fail-fast: false | ||
steps: | ||
- name: Install musl tools | ||
if: ${{ contains(matrix.target, 'musl') }} | ||
run: sudo apt-get install -y musl-tools | ||
|
||
- name: Install arm tools | ||
if: ${{ contains(matrix.target, 'arm') }} | ||
run: | | ||
echo "GNU_PREFIX=arm-linux-gnueabihf-" >> $GITHUB_ENV | ||
sudo apt-get install -y binutils-arm-linux-gnueabihf | ||
- name: Install aarch64 tools | ||
if: ${{ contains(matrix.target, 'aarch64') }} | ||
run: | | ||
echo "GNU_PREFIX=aarch64-linux-gnu-" >> $GITHUB_ENV | ||
sudo apt-get install -y binutils-aarch64-linux-gnu | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
default: true | ||
|
||
- name: Build ${{ matrix.target }} | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release --target ${{ matrix.target }} | ||
use-cross: true | ||
|
||
- name: Optimize and package binary | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
${GNU_PREFIX}strip tinysearch | ||
chmod +x tinysearch | ||
tar -c tinysearch | gzip > tinysearch.tar.gz | ||
- name: Upload binary | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
asset_name: tinysearch-${{needs.prepare.outputs.tag_name}}-${{ matrix.target }}.tar.gz | ||
asset_path: target/${{ matrix.target }}/release/tinysearch.tar.gz | ||
upload_url: ${{needs.prepare.outputs.upload_url}} | ||
asset_content_type: application/gzip | ||
|
||
macos: | ||
runs-on: macos-latest | ||
needs: prepare | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
default: true | ||
|
||
- name: Build binary | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release | ||
use-cross: true | ||
|
||
- name: Optimize and package binary | ||
run: | | ||
cd target/release | ||
strip tinysearch | ||
chmod +x tinysearch | ||
mkdir dmg | ||
mv tinysearch dmg/ | ||
hdiutil create -fs HFS+ -srcfolder dmg -volname tinysearch tinysearch.dmg | ||
- name: Upload binary | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
asset_name: tinysearch-${{needs.prepare.outputs.tag_name}}-macos-x86_64.dmg | ||
asset_path: target/release/tinysearch.dmg | ||
upload_url: ${{needs.prepare.outputs.upload_url}} | ||
asset_content_type: application/octet-stream | ||
|
||
windows: | ||
runs-on: windows-latest | ||
needs: prepare | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
default: true | ||
|
||
- name: Build binary | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release | ||
use-cross: true | ||
|
||
- name: Upload binary | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
asset_name: tinysearch-${{needs.prepare.outputs.tag_name}}-windows-x86_64.exe | ||
asset_path: target/release/tinysearch.exe | ||
upload_url: ${{needs.prepare.outputs.upload_url}} | ||
asset_content_type: application/octet-stream |