xmr-btc-swap/.github/workflows/release-cli.yml

84 lines
2.7 KiB
YAML
Raw Normal View History

name: "Release swap_cli"
on:
release:
types: [created]
jobs:
release:
name: Release swap_cli
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
2021-03-03 23:16:33 -05:00
archive_ext: tar
- target: x86_64-apple-darwin
os: macos-latest
2021-03-03 23:16:33 -05:00
archive_ext: tar
- target: x86_64-pc-windows-msvc
os: windows-latest
2021-03-03 23:16:33 -05:00
archive_ext: zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout tagged commit
uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
2021-03-04 01:47:39 -05:00
- uses: Swatinem/rust-cache@v1.2.0
- name: Build ${{ matrix.target }} release binary
run: cargo build --target=${{ matrix.target }} --release --package swap --bin swap_cli
- name: Smoke test the binary
run: target/${{ matrix.target }}/release/swap_cli --help
# Remove once python 3 is the default
- uses: actions/setup-python@v1
with:
python-version: '3.x'
2021-03-03 23:16:33 -05:00
- id: create-archive-name
shell: python # Use python to have a prettier name for the archive on Windows.
run: |
import platform
os_info = platform.uname()
2021-03-03 23:16:33 -05:00
arch = os_info.machine
2021-03-03 23:16:33 -05:00
triple = "${{ matrix.target }}".split("-")
arch = triple[0]
2021-03-03 23:16:33 -05:00
archive_name=f'swap_cli_${{ github.event.release.tag_name }}_{os_info.system}_{arch}.${{ matrix.archive_ext }}'
2021-03-03 23:16:33 -05:00
print(f'::set-output name=archive::{archive_name}')
- name: Pack macos archive
if: matrix.os == 'macos-latest'
shell: bash
run: gtar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} swap_cli
- name: Pack linux archive
if: matrix.os == 'ubuntu-latest'
shell: bash
run: tar -C ./target/${{ matrix.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} swap_cli
- name: Pack windows archive
if: matrix.os == 'windows-latest'
shell: bash
run: |
cp target/${{ matrix.target }}/release/swap_cli.exe ./swap_cli.exe
7z a -tzip ${{ steps.create-archive-name.outputs.archive }} ./swap_cli.exe
2021-03-03 23:16:33 -05:00
- name: Upload archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
2021-03-03 23:16:33 -05:00
asset_path: ./${{ steps.create-archive-name.outputs.archive }}
asset_name: ${{ steps.create-archive-name.outputs.archive }}
asset_content_type: application/gzip