Skip to content

Add publish crate workflow #23

Add publish crate workflow

Add publish crate workflow #23

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- '**' # every branch
- '!nobuild-**' # unless marked as nobuild
tags:
- '**'
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- type: windows-x64
os: windows-latest
target: x86_64-pc-windows-msvc
- type: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: Build (${{ matrix.type }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
shell: bash
run: |
cargo build --verbose --locked --release
- name: Post-build
id: postbuild
shell: bash
run: |
name="dxm-${{ matrix.type }}"
cd target/release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
name="$name.exe"
mv "dxm.exe" "../../$name"
else
mv "dxm" "../../$name"
fi
cd ../..
echo "name=$name" >> $GITHUB_OUTPUT
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: ${{ steps.postbuild.outputs.name }}
path: ./${{ steps.postbuild.outputs.name }}
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download archives
uses: actions/download-artifact@v4
- name: Archive
shell: bash
run: |
version="${{ github.ref_name }}"
mv -vfT "dxm-windows-x64.exe/dxm-windows-x64.exe" "dxm.exe"
7z a "dxm-$version-windows-x64.zip" "dxm.exe"
mv -vfT "dxm-linux-x64/dxm-linux-x64" "dxm"
tar -cjvf "dxm-$version-linux-x64.tar.gz" "dxm"
- name: Draft release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
files: |
./*.zip
./*.tar.gz