Skip to content

增加readme和示例视频 #1

增加readme和示例视频

增加readme和示例视频 #1

Workflow file for this run

name: Rust Build and Release
on:
push:
branches:
- main
jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [windows]
include:
- build: windows
os: windows-2019
rust: 1.76.0
target: x86_64-pc-windows-gnu
archive-name: windows.7z
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Build binary
run: cargo build --verbose --release --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- name: Extract info from Cargo.toml
id: extract_info
shell: bash
run: |
echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r .packages[0].version)" >> $GITHUB_ENV
echo "PACKAGE_NAME=$(cargo metadata --format-version=1 --no-deps | jq -r .packages[0].name)" >> $GITHUB_ENV
- name: Strip binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/${{ env.PACKAGE_NAME }}"
- name: Build archive
shell: bash
run: |
mkdir archive
cp LICENSE README.md archive/
cd archive
if [ "${{ matrix.build }}" = "windows" ]; then
cp "../target/${{ matrix.target }}/release/${{ env.PACKAGE_NAME }}.exe" ./
7z a "${{ matrix.archive-name }}" LICENSE README.md ${{ env.PACKAGE_NAME }}.exe
else
cp "../target/${{ matrix.target }}/release/${{ env.PACKAGE_NAME }}" ./
tar -czf "${{ matrix.archive-name }}" LICENSE README.md ${{ env.PACKAGE_NAME }}
fi
- name: Upload archive as workflow artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.archive-name }}
path: archive/${{ matrix.archive-name }}
release:
name: Release
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Extract info from Cargo.toml
id: extract_info
run: |
echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r .packages[0].version)" >> $GITHUB_ENV
echo "PACKAGE_NAME=$(cargo metadata --format-version=1 --no-deps | jq -r .packages[0].name)" >> $GITHUB_ENV
- name: Download all build artifacts
uses: actions/download-artifact@v3
with:
path: downloaded_artifacts
- name: List downloaded artifacts
run: ls -R downloaded_artifacts
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ env.VERSION }}"
name: "${{ env.PACKAGE_NAME }}-${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload ${{ env.PACKAGE_NAME }}-windows.7z to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: downloaded_artifacts/windows.7z/windows.7z
asset_name: ${{ env.PACKAGE_NAME }}-windows.7z
asset_content_type: application/x-7z-compressed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}