Skip to content

build-release

build-release #41

Workflow file for this run

on:
repository_dispatch:
types: [build-release]
name: Builds
jobs:
build:
name: Build
runs-on: "${{ matrix.os }}"
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: .exe
steps:
- name: Checkout
uses: actions/checkout@v3
- id: get_version
run: echo ::set-output name=VERSION::${PAYLOAD_REF/refs\/tags\//}
shell: bash
env:
PAYLOAD_REF: ${{ github.event.client_payload.ref }}
- id: get_repository_name
run: echo ::set-output name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
shell: bash
- uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: "${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions/cache@v2
with:
path: ~/.cargo/git
key: "${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}"
- uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
env:
VERSION: "${{ steps.get_version.outputs.VERSION }}"
REPOSITORY_NAME: "${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}"
with:
command: build
args: "--release"
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}
path: ./target/release/${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}${{ matrix.suffix }}
release:
name: Release
needs: build
runs-on: ubuntu-latest
steps:
- id: get_version
run: echo ::set-output name=VERSION::${PAYLOAD_REF/refs\/tags\//}
shell: bash
env:
PAYLOAD_REF: ${{ github.event.client_payload.ref }}
- name: Create release
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_TOKEN }}
event-type: create-release
client-payload: '{"version": "${{ steps.get_version.outputs.VERSION }}"}'