Update rust.yml

This commit is contained in:
2024-08-22 01:34:08 +02:00
committed by GitHub
parent e67ac4cc94
commit 35bd9040cb

View File

@@ -1,77 +1,71 @@
name: Deploy name: Release
on: on:
push: push:
tags: branches:
- "[0-9]+.[0-9]+.[0-9]+" - master
permissions:
contents: write
jobs: jobs:
build-and-upload: build:
name: Build and upload runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
# You can add more, for any target you'd like! target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-gnu]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
steps: steps:
- name: Checkout - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Get the release version from the tag - name: Set up Rust
shell: bash uses: actions-rs/toolchain@v1
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:
# Make Rust compile to our target (defined in the matrix) toolchain: stable
targets: ${{ matrix.target }}
- name: Build - name: Build
uses: actions-rs/cargo@v1 run: cargo build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with: with:
use-cross: true name: ${{ matrix.target }}-binary
command: build path: target/${{ matrix.target }}/release/
args: --verbose --release --target ${{ matrix.target }}
- name: Build archive release:
shell: bash needs: build
run: | runs-on: ubuntu-latest
# Replace with the name of your binary
binary_name="BeetleWire"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" steps:
mkdir "$dirname" - name: Checkout code
if [ "${{ matrix.os }}" = "windows-latest" ]; then uses: actions/checkout@v2
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then - name: Create Release
7z a "$dirname.zip" "$dirname" id: create_release
echo "ASSET=$dirname.zip" >> $GITHUB_ENV uses: actions/create-release@v1
else env:
tar -czf "$dirname.tar.gz" "$dirname" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@v1
with: with:
files: | tag_name: v${{ github.run_number }}
${{ env.ASSET }} release_name: Release ${{ github.run_number }}
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: target/x86_64-pc-windows-gnu/release/
asset_name: windows-binary.zip
asset_content_type: application/zip
- 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: target/x86_64-unknown-linux-gnu/release/
asset_name: linux-binary.tar.gz
asset_content_type: application/gzip