chore: Update Rust workflow to build and test in release mode, create… #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust Build and Publish | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v2 | |
- name: Install Rust toolchain | |
run: rustup target add x86_64-pc-windows-gnu | |
- name: Set up Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: x86_64-pc-windows-gnu | |
override: true | |
- name: Install mingw | |
run: sudo apt-get install mingw-w64 -y | |
- name: Build the project | |
run: cargo build --release --target x86_64-pc-windows-gnu | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: rust-app | |
path: target/x86_64-pc-windows-gnu/release/ml2pdf.exe | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: rust-app | |
path: target/x86_64-pc-windows-gnu/release | |
- name: Get current date | |
id: get_date | |
run: echo "DATE=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
- name: Publish release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.DATE }} | |
release_name: Release ${{ env.DATE }} | |
draft: false | |
prerelease: false | |
- name: Upload exe to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: target/x86_64-pc-windows-gnu/release/ml2pdf.exe | |
asset_name: ml2pdf.exe | |
asset_content_type: application/octet-stream |