Skip to content

Merge pull request #148 from jannic-dev-forks/fix-ci #12

Merge pull request #148 from jannic-dev-forks/fix-ci

Merge pull request #148 from jannic-dev-forks/fix-ci #12

Workflow file for this run

name: release
on:
push:
branches:
- master
tags:
- v*.*.*
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, suffix: .tar.gz }
- { target: x86_64-apple-darwin, os: macos-latest, suffix: .tar.gz }
- { target: aarch64-apple-darwin, os: macos-latest, suffix: .tar.gz }
- { target: x86_64-pc-windows-msvc, os: windows-latest, suffix: .zip }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Rust
shell: bash
run: |
rustup toolchain install stable --profile minimal
rustup default stable
echo "::add-matcher::.github/workflows/rust.json"
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- run: cargo build --target ${{ matrix.target }} --release
- name: (Not Windows) Move executables and compress
if: ${{ matrix.os != 'windows-latest' }}
run: |
mkdir ${{ matrix.target }}
for bin in src/bin/*.rs; do
mv target/${{ matrix.target }}/release/$(basename $bin .rs) ${{ matrix.target }};
done
tar -zcvf ${{ matrix.target }}.tar.gz ${{ matrix.target }}
- name: (Windows) Move executables and compress
if: ${{ matrix.os == 'windows-latest' }}
run: |
mkdir ${{ matrix.target }}
$bins = Get-ChildItem -Path src/bin -Recurse -Filter "*.rs"
foreach ($b in $bins) {
Move-Item -Path ("target/${{ matrix.target }}/release/" + $b.BaseName + ".exe") -Destination "${{ matrix.target }}/"
}
Compress-Archive -Path ${{ matrix.target }} -DestinationPath ${{ matrix.target }}.zip
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: ${{ matrix.target }}${{ matrix.suffix }}
release:
name: release
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
path: artifacts
- run: ls -R ./artifacts
- name: Set current date as environment variable
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- id: changelog-reader
uses: mindsers/[email protected]
with:
version: ${{ (github.ref_type == 'tag' && github.ref_name) || 'Unreleased' }}
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.changelog-reader.outputs.version }}
name: ${{ (github.ref_type == 'tag' && steps.changelog-reader.outputs.version) || format('Prereleased {0}', env.CURRENT_DATE) }}
body: ${{ steps.changelog-reader.outputs.changes }}
prerelease: ${{ steps.changelog-reader.outputs.status == 'unreleased' }}
files: |
artifacts/**/*