Skip to content

Commit 19aebac

Browse files
committed
ci(github-actions): simplify and consolidate Rust demo workflow
- Merge duplicate toolchain installation steps and broaden OS condition to include `ubuntu24` - Remove redundant `Install toolchains` block for `ubuntu24` - Consolidate binary copy logic into a single step with OS‑specific handling for `.exe` files - Refactor `gitbundle-xtask` execution into one unified step, adding conditional arguments for the mingw path on `ubuntu24-gnullvm` - Clean up unnecessary `if` conditions and streamline shell commands for better readability and maintenance.
1 parent b636282 commit 19aebac

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

.github/workflows/rust-demo.yml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
# token: ${{secrets.GITBUNDLE_TOKEN}}
6868

6969
- name: Install toolchains
70-
if: ${{ matrix.os == 'ubuntu24-gnullvm' && vars.install_toolchains == 'true' }}
70+
if: ${{ (matrix.os == 'ubuntu24-gnullvm' || matrix.os == 'ubuntu24') && vars.install_toolchains == 'true' }}
7171
shell: bash
7272
run: |
7373
sudo apt update
@@ -77,17 +77,6 @@ jobs:
7777
llvm-dev \
7878
jq
7979
80-
- name: Install toolchains
81-
if: ${{ matrix.os == 'ubuntu24' && vars.install_toolchains == 'true' }}
82-
shell: bash
83-
run: |
84-
apt update
85-
apt install -y \
86-
clang \
87-
libclang-dev \
88-
llvm-dev \
89-
jq
90-
9180
- name: Setup Rust Target
9281
run: rustup target add "${{ matrix.target }}"
9382

@@ -122,20 +111,17 @@ jobs:
122111
run: mkdir -p "$RELEASE_DIR"
123112

124113
- name: Copy Binary to Release Dir
125-
if: ${{ matrix.os == 'ubuntu24-gnullvm' }}
126114
shell: bash
127115
run: |
128116
SRC_PATH="target/${{ matrix.target }}/release/${PROJECT_NAME}"
129117
BIN_NAME="${{ matrix.name }}"
130-
cp "${SRC_PATH}.exe" "${RELEASE_DIR}/${PROJECT_NAME}-${BIN_NAME}.exe"
118+
DEST="${RELEASE_DIR}/${PROJECT_NAME}-${BIN_NAME}"
131119
132-
- name: Copy Binary to Release Dir
133-
if: ${{ matrix.os != 'ubuntu24-gnullvm' }}
134-
shell: bash
135-
run: |
136-
SRC_PATH="target/${{ matrix.target }}/release/${PROJECT_NAME}"
137-
BIN_NAME="${{ matrix.name }}"
138-
cp "$SRC_PATH" "${RELEASE_DIR}/${PROJECT_NAME}-${BIN_NAME}"
120+
if [[ "${{ matrix.os }}" == "ubuntu24-gnullvm" ]]; then
121+
cp "${SRC_PATH}.exe" "${DEST}.exe"
122+
else
123+
cp "${SRC_PATH}" "${DEST}"
124+
fi
139125
140126
- name: Install gitbundle-xtask
141127
if: vars.install_gitbundle_xtask == 'true'
@@ -145,21 +131,21 @@ jobs:
145131
cargo binstall gitbundle-xtask -y
146132
147133
- name: Run gitbundle-xtask
148-
if: ${{ matrix.os == 'ubuntu24-gnullvm' }}
134+
shell: bash
149135
run: |
150-
gitbundle-xtask \
151-
--binary-file "${RELEASE_DIR}/${PROJECT_NAME}-${{ matrix.name }}.exe" \
152-
--target-name ${PROJECT_NAME} \
153-
--output-path dist \
154-
--mingw-path $LLVM_MINGW_ROOT
136+
BIN_PATH="${RELEASE_DIR}/${PROJECT_NAME}-${{ matrix.name }}"
137+
138+
EXTRA_ARGS=()
139+
if [[ "${{ matrix.os }}" == "ubuntu24-gnullvm" ]]; then
140+
BIN_PATH="${BIN_PATH}.exe"
141+
EXTRA_ARGS+=(--mingw-path "$LLVM_MINGW_ROOT")
142+
fi
155143
156-
- name: Run gitbundle-xtask
157-
if: ${{ matrix.os != 'ubuntu24-gnullvm' }}
158-
run: |
159144
gitbundle-xtask \
160-
--binary-file "${RELEASE_DIR}/${PROJECT_NAME}-${{ matrix.name }}" \
161-
--target-name ${PROJECT_NAME} \
162-
--output-path dist
145+
--binary-file "$BIN_PATH" \
146+
--target-name "${PROJECT_NAME}" \
147+
--output-path dist \
148+
"${EXTRA_ARGS[@]}"
163149
164150
- name: Show Dist Built
165151
run: ls -la dist/

0 commit comments

Comments
 (0)