name: Publish
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
target: ['x86_64-unknown-linux-gnu', 'x86_64-pc-windows-msvc', 'x86_64-apple-darwin', 'aarch64-apple-darwin']
include:
- target: 'x86_64-pc-windows-msvc'
os: windows-latest
suffix: '.exe'
- target: 'x86_64-apple-darwin'
os: macos-latest
- target: 'aarch64-apple-darwin'
os: macos-latest
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/whatip${{ matrix.suffix }}
- name: Create tar artifact
run: |
tar -czf whatip-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release whatip${{ matrix.suffix }}
shasum -a 256 whatip-${{ matrix.target }}.tar.gz
- name: Upload tar Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}-tar
path: '*.tar.gz'
- name: Rename binary
run: mv target/${{ matrix.target }}/release/whatip${{ matrix.suffix }} ./whatip-${{ matrix.target }}
- name: Upload artifacts to release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |
./whatip-${{ matrix.target }}
*.tar.gz