Skip to content

Commit

Permalink
build: Customize binary name and improve release workflow debugging
Browse files Browse the repository at this point in the history
- Added BINARY_NAME environment variable for consistent artifact naming
- Simplified project name extraction from repository name
- Enhanced build step with debug information and directory listing
- Updated archive and binary path generation to use custom binary name
- Removed redundant project name references in workflow steps
  • Loading branch information
limitcool committed Feb 14, 2025
1 parent 1c7cc7b commit cc100b1
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
permissions:
contents: write

env:
BINARY_NAME: bilistream # 定义二进制文件名称为环境变量

jobs:
create-release:
name: create-release
Expand All @@ -20,7 +23,10 @@ jobs:
if: env.VERSION == ''
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Get project name from repository name
run: echo "PROJECT_NAME=${{ github.repository }}" >> $GITHUB_ENV
run: |
repository="${{ github.repository }}"
project_name="${repository##*/}" # 只获取仓库名,去掉所有者部分
echo "PROJECT_NAME=$project_name" >> $GITHUB_ENV
- name: Show the version and project name
run: |
echo "version is: $VERSION"
Expand Down Expand Up @@ -123,12 +129,23 @@ jobs:
run: |
${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
if [ "${{ matrix.os }}" = "windows-latest" ]; then
bin="target/${{ matrix.target }}/release/${{ needs.create-release.outputs.project_name }}.exe"
bin="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe"
else
bin="target/${{ matrix.target }}/release/${{ needs.create-release.outputs.project_name }}"
bin="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
fi
echo "BIN=$bin" >> $GITHUB_ENV
# 添加调试信息
echo "=== Build Debug Info ==="
echo "Binary path: $bin"
echo "Target directory content:"
if [ "${{ matrix.target }}" ]; then
ls -la target/${{ matrix.target }}/release/
else
ls -la target/release/
fi
echo "======================="
# - name: Strip release binary (macos)
# if: matrix.os == 'macos-latest'
# shell: bash
Expand All @@ -142,14 +159,13 @@ jobs:
"$PWD/target:/target:Z" \
"ghcr.io/cross-rs/${{ matrix.target }}:main" \
"${{ matrix.strip }}" \
"/$BIN"
"/target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
- name: Determine archive name
shell: bash
run: |
version="${{ needs.create-release.outputs.version }}"
project_name="${{ needs.create-release.outputs.project_name }}"
echo "ARCHIVE=$project_name-$version-${{ matrix.target }}" >> $GITHUB_ENV
echo "ARCHIVE=${{ env.BINARY_NAME }}-$version-${{ matrix.target }}" >> $GITHUB_ENV
- name: Creating directory for archive
shell: bash
Expand Down

0 comments on commit cc100b1

Please sign in to comment.