Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: patch Cargo lockfile for release instead of build without --locked #166

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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