Build #227
  
    
      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: Build | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| only-offline: | |
| type: boolean | |
| default: false | |
| description: 'Only build offline package and upload' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| mode: [ online, offline ] | |
| env: | |
| BUILD_MODE: ${{ matrix.mode }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Override Rust Toolchain | |
| run: | | |
| $toolchain = "nightly${{ vars.RUST_NIGHTLY_VER }}".Trim() | |
| echo $toolchain | |
| echo "RUST_TOOLCHAIN=$toolchain" >> $env:GITHUB_ENV | |
| (Get-Content ./src-tauri/rust-toolchain.toml -Raw) -replace 'nightly', "$toolchain" | Set-Content ./src-tauri/rust-toolchain.toml -Encoding utf8 | |
| - run: rustup toolchain install ${{ env.RUST_TOOLCHAIN }} --profile minimal && rustup component add rust-src --toolchain ${{ env.RUST_TOOLCHAIN }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-targets: false | |
| workspaces: 'src-tauri' | |
| - uses: pnpm/[email protected] | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: 'pnpm' | |
| - name: Install NPM Dependencies | |
| run: pnpm i | |
| - name: Update Meta | |
| run: | | |
| $tag = git describe --tags --abbrev=0 2>$null | |
| if (-not $tag) { $tag = "0.0.0" } | |
| $TAG = $tag -replace '^v', '' | |
| $PKGVER = "r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)" | |
| $cstTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("China Standard Time") | |
| $utcNow = [System.DateTime]::UtcNow | |
| $cstTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($utcNow, $cstTimeZone) | |
| $BUILDMETA = $cstTime.ToString("yyMMddHHmm") | |
| (Get-Content ./src-tauri/Cargo.toml -Raw) -replace '(?m)^(version = "\d+\.\d+\.\d+)', "version = `"$TAG-$PKGVER+$BUILDMETA" | Set-Content ./src-tauri/Cargo.toml -Encoding utf8 | |
| - name: Prepare offline package and info | |
| if: ${{ env.BUILD_MODE == 'offline' }} | |
| run: | | |
| $patch = irm "https://api.snapgenshin.com/patch/hutao" | |
| $version = $patch.data.version | |
| echo "EMBEDDED_VERSION=$version" >> $env:GITHUB_ENV | |
| iwr -Uri $patch.data.urls[0] -OutFile "./src-tauri/Snap.Hutao.msix" | |
| - name: Build | |
| run: pnpm build-${{ env.BUILD_MODE }} | |
| - name: Upload PDB to Sentry | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| SENTRY_PROJECT: installer | |
| run: | | |
| pnpm add @sentry/cli | |
| ./node_modules/.bin/sentry-cli debug-files upload --include-sources ./src-tauri/target/release/hutao_installer.pdb | |
| - name: Copy Binary | |
| run: | | |
| if ("${{ env.BUILD_MODE }}" -eq "online") { | |
| $file = "Snap.Hutao.Deployment.exe" | |
| } else { | |
| $file = "Snap.Hutao.Deployment.Embedded.${{ env.EMBEDDED_VERSION }}.exe" | |
| } | |
| copy src-tauri/target/release/hutao-installer.exe $file | |
| echo "DIST_FILENAME=$file" >> $env:GITHUB_ENV | |
| - name: Artifact | |
| uses: actions/[email protected] | |
| with: | |
| name: deployment-${{ env.BUILD_MODE }} | |
| path: ${{ env.DIST_FILENAME }} | |
| - name: pdb | |
| uses: actions/[email protected] | |
| with: | |
| name: pdb-${{ env.BUILD_MODE }} | |
| path: src-tauri/target/release/hutao_installer.pdb | |
| sync: | |
| runs-on: windows-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: DGP-Studio/Snap.Hutao.Deployment | |
| token: ${{ secrets.TOKEN }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: deployment-online | |
| path: src/Snap.Hutao.Deployment.Runtime | |
| - name: Upload to object stores | |
| uses: hutao-cdn/upload@v1 | |
| with: | |
| file_path: src/Snap.Hutao.Deployment.Runtime/Snap.Hutao.Deployment.exe | |
| key: Snap.Hutao.Deployment.exe | |
| post_action: refresh | |
| env: | |
| SNAP_HUTAO_CDN_TOKEN: ${{ secrets.SNAP_HUTAO_CDN_TOKEN }} | |
| - name: Update nuspec | |
| run: | | |
| $tag = "${{ github.ref_name }}" | |
| (Get-Content ./src/Snap.Hutao.Deployment.Runtime/Snap.Hutao.Deployment.Runtime.nuspec -Raw) -replace '(?m)(<version>\d+\.\d+\.\d+</version>)', "<version>$tag</version>" | Set-Content ./src/Snap.Hutao.Deployment.Runtime/Snap.Hutao.Deployment.Runtime.nuspec -Encoding utf8 | |
| - name: Push | |
| run: | | |
| git config --global user.email "[email protected]" | |
| git add . | |
| git commit -m "Release ${{ github.ref_name }}" | |
| git push | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| target_commitish: main | |
| name: ${{ github.ref_name }} | |
| prerelease: false | |
| repository: DGP-Studio/Snap.Hutao.Deployment | |
| token: ${{ secrets.TOKEN }} | |
| files: | | |
| src/Snap.Hutao.Deployment.Runtime/Snap.Hutao.Deployment.exe | |
| sync-to-cloud-drives: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event.inputs.only-offline == 'true') }} | |
| strategy: | |
| matrix: | |
| mode: [ online, offline ] | |
| provider: [ '/qk' ] | |
| env: | |
| BUILD_MODE: ${{ matrix.mode }} | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: deployment-${{ env.BUILD_MODE }} | |
| path: ${{ env.BUILD_MODE }} | |
| - name: Get upload path | |
| id: get-upload-path | |
| run: | | |
| if [ "${{ env.BUILD_MODE }}" == "online" ]; then | |
| echo "FILENAME=online/Snap.Hutao.Deployment.exe" >> $GITHUB_OUTPUT | |
| echo "TARGET_DIR=${{ matrix.provider }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "FILENAME=$(ls offline/Snap.Hutao.Deployment.Embedded.*.exe)" >> $GITHUB_OUTPUT | |
| echo "TARGET_DIR=${{ matrix.provider }}/离线包" >> $GITHUB_OUTPUT | |
| fi | |
| - name: upload | |
| uses: DGP-Automation/alist-uploader@v1 | |
| with: | |
| file_path: ${{ steps.get-upload-path.outputs.FILENAME }} | |
| target_dir: ${{ steps.get-upload-path.outputs.TARGET_DIR }} | |
| overwrite: true | |
| env: | |
| ALIST_HOST: ${{ secrets.ALIST_HOST }} | |
| ALIST_USERNAME: ${{ secrets.ALIST_USERNAME }} | |
| ALIST_PASSWORD: ${{ secrets.ALIST_PASSWORD }} |