name: Release
on:
push:
tags: [ 'v*' ]
jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-apple-darwin
profile: minimal
default: true
- name: Cache cargo build
uses: Swatinem/rust-cache@v1
- name: Build
run: |
cargo build --release --target x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
lipo -create -output target/release/rx target/x86_64-apple-darwin/release/rx target/aarch64-apple-darwin/release/rx
- name: Get tag
if: "startsWith(github.ref, 'refs/tags/')"
id: tag
uses: dawidd6/action-get-tag@v1
- name: Archive binary
if: "startsWith(github.ref, 'refs/tags/')"
run: |
cd target/release
tar czvf rx-${{ steps.tag.outputs.tag }}-apple-darwin.tar.gz rx
- name: Upload binary artifacts
if: "startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
with:
name: binaries
path: target/release/rx-${{ steps.tag.outputs.tag }}-apple-darwin.tar.gz
windows:
runs-on: windows-latest
strategy:
matrix:
target:
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-python@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
default: true
- name: Cache cargo build
uses: Swatinem/rust-cache@v1
- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
- name: Get tag
if: "startsWith(github.ref, 'refs/tags/')"
id: tag
uses: dawidd6/action-get-tag@v1
- name: Archive binary
if: "startsWith(github.ref, 'refs/tags/')"
run: |
cd target/${{ matrix.target }}/release
7z a rx-${{ steps.tag.outputs.tag }}-${{ matrix.target }}.zip rx.exe
- name: Upload binary artifacts
if: "startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
with:
name: binaries
path: target/${{ matrix.target }}/release/rx-${{ steps.tag.outputs.tag }}-${{ matrix.target }}.zip
linux:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [
{ target: "x86_64-unknown-linux-musl", image_tag: "x86_64-musl" },
{ target: "i686-unknown-linux-musl", image_tag: "i686-musl" },
{ target: "aarch64-unknown-linux-musl", image_tag: "aarch64-musl" },
{ target: "armv7-unknown-linux-musleabihf", image_tag: "armv7-musleabihf" },
]
container:
image: docker://messense/rust-musl-cross:${{ matrix.platform.image_tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Cache cargo build
uses: Swatinem/rust-cache@v1
with:
key: ${{ matrix.platform.target }}
- name: Build
run: |
rustup target add ${{ matrix.platform.target }}
cargo build --release --target ${{ matrix.platform.target }}
- name: Get tag
if: "startsWith(github.ref, 'refs/tags/')"
id: tag
uses: dawidd6/action-get-tag@v1
- name: Archive binary
if: "startsWith(github.ref, 'refs/tags/')"
run: |
cd target/${{ matrix.platform.target }}/release
tar czvf rx-${{ steps.tag.outputs.tag }}-${{ matrix.platform.target }}.tar.gz rx
- name: Upload binary artifacts
if: "startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v2
with:
name: binaries
path: target/${{ matrix.platform.target }}/release/rx-${{ steps.tag.outputs.tag }}-${{ matrix.platform.target }}.tar.gz
release:
name: Publish to GitHub releases
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, windows, linux ]
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/download-artifact@v2
with:
name: binaries
- name: Set variables
id: vars
run: |
CHANGELOG=$(awk '/^## v/ {n=NR; i++}; i==1 {if (NR==n) {print "## Release Notes"} else {print}}; i>1 {exit}' CHANGELOG.md \
| python3 -c 'import sys, json; print(json.dumps(sys.stdin.read()))')
echo "::set-output name=changelog::$CHANGELOG"
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
*.tar.gz
*.zip
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: true
body: ${{ fromJson(steps.vars.outputs.changelog) }}