diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad2dc4ef..ddf260d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,7 +91,6 @@ jobs: echo '```' } >> "$GITHUB_STEP_SUMMARY" - build: name: Build needs: meta @@ -119,25 +118,33 @@ jobs: with: os: ${{ matrix.os }} arch: ${{ matrix.arch }} - - name: Patch Cargo.toml (BSD sed) - if: ${{ startsWith(matrix.os, 'macos') }} - working-directory: maa-cli - run: | - sed -i "" '1,6 s/^version = .*/version = "${{ needs.meta.outputs.version }}"/' Cargo.toml - git diff Cargo.toml - - name: Patch Cargo.toml (GNU sed) - if: ${{ !startsWith(matrix.os, 'macos') }} - working-directory: maa-cli + - name: Patch Version run: | - sed -i '1,6 s/^version = .*/version = "${{ needs.meta.outputs.version }}"/' Cargo.toml - git diff Cargo.toml + MAA_VERSION="${{ needs.meta.outputs.version }}" + if [ $(uname) == "Darwin" ]; then + SED="sed -i '' -E" # BSD sed should use '' as backup extension + else + SED="sed -i -E" + fi + S="[[:space:]]" # BSD sed doesn't support \s + $SED "1,6 s/(version${S}*=${S}*)\"[^\"]+\"/\1\"$MAA_VERSION\"/" maa-cli/Cargo.toml + NL=$(grep -n -E "name${S}*=${S}*\"maa-cli\"" Cargo.lock | cut -d: -f1) + NS=$((NL - 1)) + NE=$((NL + 3)) + $SED "$NS,$NE s/(version${S}*=${S}*)\"[^\"]+\"/\1\"$MAA_VERSION\"/" Cargo.lock + { + echo "Patch Version (${{ matrix.os }}, ${{ matrix.arch }})" + echo '```diff' + git diff + echo '```' + } >> "$GITHUB_STEP_SUMMARY" - name: Build env: CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1 CARGO_PROFILE_RELEASE_LTO: true CARGO_PROFILE_RELEASE_STRIP: true run: | - cargo build --release --package maa-cli \ + cargo build --release --package maa-cli --locked \ ${{ matrix.arch != 'x86_64' && '--features git2/vendored-openssl,reqwest/native-tls-vendored' || '' }} - name: Tar Artifact run: |