Skip to content

Release

Release #11

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
cross: true
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Create archive (Unix)
if: matrix.archive == 'tar.gz'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/cp2md dist/
cp LICENSE dist/
cd dist
tar -czvf ../cp2md-${{ github.ref_name }}-${{ matrix.target }}.tar.gz *
- name: Create archive (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target/${{ matrix.target }}/release/cp2md.exe" -Destination dist/
Copy-Item LICENSE -Destination dist/
Compress-Archive -Path dist/* -DestinationPath "cp2md-${{ github.ref_name }}-${{ matrix.target }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cp2md-${{ matrix.target }}
path: cp2md-${{ github.ref_name }}-${{ matrix.target }}.*
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: true