feat(fs): 支持CORS #27
Workflow file for this run
This file contains hidden or 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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: build ${{ matrix.file }} on ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - windows-latest | |
| - ubuntu-latest # target: x86_64-unknown-linux-musl | |
| - macos-latest | |
| file: | |
| - ${{ github.event.repository.name }} | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| # 不同构建目标对应的 release 目录 | |
| TARGET: ${{ matrix.os == 'ubuntu-latest' && 'target/x86_64-unknown-linux-musl/release' || 'target/release' }} | |
| # 构建文件名, Windows 平台有 .exe 后缀 | |
| NAME: ${{ format('{0}{1}', matrix.file, startsWith(matrix.os, 'windows') && '.exe' || '') }} | |
| # 上传制品文件名 | |
| ARTIFACT_NAME: Binary-${{ matrix.file }}-${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@master | |
| with: | |
| submodules: recursive # 递归检出git子模块(submodules) | |
| - name: Cache | |
| id: cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo | |
| ~/.rustup | |
| ./target | |
| key: ${{ runner.os }}-${{ matrix.file }}-cache | |
| - name: musl-tools | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt install -y musl-tools | |
| - name: Rustup | |
| if: steps.cache.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest' | |
| run: | | |
| rustup target add x86_64-unknown-linux-musl | |
| - name: Build | |
| env: | |
| CARGO_TERM_COLOR: always | |
| run: | | |
| cargo build --release --verbose \ | |
| ${{ matrix.os == 'ubuntu-latest' && '--target x86_64-unknown-linux-musl' || '--' }} | |
| - name: Naming ${{ env.NAMING }} | |
| id: naming | |
| env: | |
| NAMING: >- | |
| ${{ | |
| format('{0}-{1}-{2}-{3}{4}', | |
| matrix.file, github.ref_name, runner.os, runner.arch, | |
| startsWith(matrix.os, 'windows') && '.exe' || '' | |
| ) | |
| }} | |
| run: | | |
| export NAMING="$( echo ${{ env.NAMING }} | tr [:upper:] [:lower:] )" | |
| echo "FILEPATH=$TARGET/$NAMING" >> $GITHUB_OUTPUT | |
| - name: Rename file | |
| run: | | |
| mv "$TARGET/$NAME" ${{ steps.naming.outputs.FILEPATH }} | |
| - name: Upload | |
| uses: actions/upload-artifact@master | |
| id: artifact-upload-step | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: ${{ steps.naming.outputs.FILEPATH }} | |
| - name: GH Release on ${{ matrix.os }} | |
| uses: softprops/action-gh-release@v2.0.2 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: ${{ steps.naming.outputs.FILEPATH }} | |
| - name: Done | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| echo "### [${{ github.ref_name }}](https://github.com/$GITHUB_REPOSITORY/releases/tag/${{ github.ref_name }}) Released! :rocket:" \ | |
| >> $GITHUB_STEP_SUMMARY | |
| permissions: | |
| contents: write |