fix: 修复sftool_param的调用方式 (#49) #33
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
| # This is a basic workflow to help you get started with Actions | |
| name: Build and Release | |
| # Controls when the workflow will run | |
| on: | |
| push: | |
| branches: [master] | |
| tags: ['*'] | |
| workflow_dispatch: | |
| pull_request: | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| # This workflow contains a single job called "build" | |
| build: | |
| # The type of runner that the job will run on | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| build: [linux, macos, windows, macos-intel, linux-aarch64, linux-i686, windows-i686] | |
| include: | |
| - build: linux | |
| os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| - build: macos | |
| os: macos-latest | |
| target: aarch64-apple-darwin | |
| - build: windows | |
| os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| - build: macos-intel | |
| os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| - build: linux-aarch64 | |
| os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| - build: linux-i686 | |
| os: ubuntu-latest | |
| target: i686-unknown-linux-gnu | |
| - build: windows-i686 | |
| os: windows-latest | |
| target: i686-pc-windows-msvc | |
| fail-fast: false | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Cache cargo artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Prepare env | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| profile: minimal | |
| override: true | |
| - name: Prepare deps on macOS | |
| if: runner.os == 'macos' | |
| run: "brew install coreutils" | |
| - name: Prepare cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build | |
| run: cross build --release --target ${{ matrix.target }} | |
| env: | |
| CROSS_NO_WARNINGS: 0 | |
| - name: Set sanitized version | |
| id: version | |
| run: | | |
| SANITIZED_VERSION=$(echo '${{ github.ref_name }}' | sed 's/\//-/g') | |
| echo "value=$SANITIZED_VERSION" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Create Zip Archive and sha256 | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| $version = "${{ steps.version.outputs.value }}" | |
| Write-Host "Tag version: $version" | |
| $zipFile = "sftool-$version-${{matrix.target}}.zip" | |
| Compress-Archive -Path "target/${{matrix.target}}/release/sftool.exe" -DestinationPath $zipFile | |
| $hash = Get-FileHash -Path $zipFile -Algorithm SHA256 | |
| Write-Host "SHA256: $($hash.Hash)" | |
| $hash = Get-FileHash -Algorithm SHA256 -Path $zipFile | Select-Object -ExpandProperty Hash | |
| $hash | Out-File -Encoding ASCII "$zipFile.sha256" | |
| shell: pwsh | |
| - name: Create tar.xz Archive and sha256 | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| version="${{ steps.version.outputs.value }}" | |
| echo "Tag version: $version" | |
| tar -cJf "sftool-$version-${{matrix.target}}.tar.xz" -C "target/${{matrix.target}}/release" sftool | |
| sha256sum "sftool-$version-${{matrix.target}}.tar.xz" > "sftool-$version-${{matrix.target}}.tar.xz.sha256" | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sftool-${{ matrix.target }}-${{ steps.version.outputs.value }} | |
| path: | | |
| sftool-*.zip | |
| sftool-*.tar.xz | |
| sftool-*.sha256 | |
| publish-crates: | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libudev-dev | |
| - name: Cache cargo artifacts | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| profile: minimal | |
| override: true | |
| - name: Publish sftool-lib crate | |
| run: cargo publish -p sftool-lib | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
| - name: Wait for crates.io index update | |
| run: sleep 60 | |
| - name: Publish sftool crate | |
| run: cargo publish -p sftool | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
| publish-release: | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: sftool-* | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Create Release and Upload Assets | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ github.ref_name }} | |
| allowUpdates: true | |
| generateReleaseNotes: true | |
| artifacts: | | |
| artifacts/sftool-*.zip | |
| artifacts/sftool-*.tar.xz | |
| artifacts/sftool-*.sha256 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| sync-cos: | |
| if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
| needs: | |
| - publish-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: sftool-* | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Install upload tools | |
| run: | | |
| pip install --upgrade pip | |
| pip install coscmd tccli | |
| - name: Configure COSCMD | |
| run: | | |
| coscmd config -a ${{ secrets.COS_DOCS_SECRET_ID }} -s ${{ secrets.COS_DOCS_SECRET_KEY }} -b ${{ secrets.COS_DOWNLOAD_BUCKET }} -r ${{ secrets.COS_DOWNLOAD_REGION }} | |
| - name: Upload to COS | |
| run: | | |
| coscmd upload -rs --delete --yes artifacts/ github_assets/OpenSiFli/sftool/releases/download/${{ github.ref_name }}/ | |
| - name: Purge CDN Cache | |
| env: | |
| TENCENTCLOUD_SECRET_ID: ${{ secrets.COS_DOCS_SECRET_ID }} | |
| TENCENTCLOUD_SECRET_KEY: ${{ secrets.COS_DOCS_SECRET_KEY }} | |
| TENCENTCLOUD_REGION: ${{ secrets.COS_DOWNLOAD_REGION }} | |
| run: | | |
| tccli cdn PurgePathCache --cli-unfold-argument --Paths 'https://downloads.sifli.com/github_assets/OpenSiFli/sftool/releases/download/' --FlushType flush |