Skip to content

Commit

Permalink
ci: patch Cargo lockfile for release instead of build without `--lock…
Browse files Browse the repository at this point in the history
…ed` (#166)
  • Loading branch information
wangl-cc authored Jan 3, 2024
1 parent 3e3021d commit cb1a77e
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ jobs:
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
build:
name: Build
needs: meta
Expand Down Expand Up @@ -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: |
Expand Down

0 comments on commit cb1a77e

Please sign in to comment.