Update rust.yml

This commit is contained in:
2024-08-22 01:28:56 +02:00
committed by GitHub
parent d93fd1db58
commit e67ac4cc94

View File

@@ -1,85 +1,77 @@
name: Build and Release name: Deploy
on: on:
push: push:
branches: tags:
- master - "[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
jobs: jobs:
build: build-and-upload:
name: Build and upload
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] # You can add more, for any target you'd like!
target: [x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-gnu]
include: include:
- os: ubuntu-latest - build: linux
target: x86_64-unknown-linux-gnu os: ubuntu-latest
- os: macos-latest target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-gnu
steps: steps:
- name: Checkout code - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up Rust - name: Get the release version from the tag
uses: actions-rs/toolchain@v1 shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust
# Or @nightly if you want
uses: dtolnay/rust-toolchain@stable
# Arguments to pass in
with: with:
toolchain: stable # Make Rust compile to our target (defined in the matrix)
targets: ${{ matrix.target }}
- name: Build - name: Build
run: cargo build --release --target ${{ matrix.target }} uses: actions-rs/cargo@v1
- name: Upload artifact
uses: actions/upload-artifact@v2
with: with:
name: ${{ matrix.os }}-binary use-cross: true
path: target/${{ matrix.target }}/release/your_binary_name command: build
args: --verbose --release --target ${{ matrix.target }}
release: - name: Build archive
needs: build shell: bash
runs-on: ubuntu-latest run: |
steps: # Replace with the name of your binary
- name: Checkout code binary_name="BeetleWire"
uses: actions/checkout@v2
- name: Get Previous Tag dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
id: previoustag mkdir "$dirname"
uses: WyriHaximus/github-action-get-previous-tag@v1 if [ "${{ matrix.os }}" = "windows-latest" ]; then
env: mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
- name: Get Next SemVer if [ "${{ matrix.os }}" = "windows-latest" ]; then
id: semvers 7z a "$dirname.zip" "$dirname"
uses: WyriHaximus/github-action-next-semvers@v1 echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@v1
with: with:
version: ${{ steps.previoustag.outputs.tag }} files: |
${{ env.ASSET }}
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: ${{ matrix.os }}-binary
path: ./artifacts
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.semvers.outputs.v_patch }}
release_name: Release ${{ steps.semvers.outputs.v_patch }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts
asset_name: BeetleWire_${{ matrix.os }}
asset_content_type: application/octet-stream