Skip to content

Commit 8053348

Browse files
authored
[CI] Create archive-install action and simplify workflows (#469)
- add an `archive-install` composite action - refactor `ubuntu.yml`, `mac.yml` and `windows.yml` to use the new action
1 parent d1764d8 commit 8053348

File tree

4 files changed

+50
-45
lines changed

4 files changed

+50
-45
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Archive installed package
2+
inputs:
3+
path:
4+
description: Directory to archive
5+
required: true
6+
name:
7+
description: Artifact name
8+
required: true
9+
runs:
10+
using: composite
11+
steps:
12+
- id: set-archive
13+
shell: bash
14+
run: |
15+
if [ "${RUNNER_OS}" = "Windows" ]; then
16+
echo "archive=${{ inputs.name }}.zip" >> "$GITHUB_OUTPUT"
17+
else
18+
echo "archive=${{ inputs.name }}.tar.gz" >> "$GITHUB_OUTPUT"
19+
fi
20+
- name: Compress directory (unix)
21+
if: runner.os != 'Windows'
22+
shell: bash
23+
run: tar -czvf "${{ steps.set-archive.outputs.archive }}" -C "${{ inputs.path }}" .
24+
- name: Compress directory (windows)
25+
if: runner.os == 'Windows'
26+
shell: pwsh
27+
run: Compress-Archive -Path ${{ inputs.path }} -DestinationPath ${{ steps.set-archive.outputs.archive }}
28+
- name: Upload artifact
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: ${{ inputs.name }}
32+
path: ${{ steps.set-archive.outputs.archive }}

.github/workflows/mac.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ jobs:
3636
run: |
3737
cmake --build build --target install
3838
- name: Archive installed package
39-
run: |
40-
tar -czvf macos-clang-sanitizer-install.tar.gz -C install .
41-
- name: Upload installed package
42-
uses: actions/upload-artifact@v4
39+
uses: ./.github/actions/archive-install
4340
with:
41+
path: install
4442
name: macos-clang-sanitizer-install
45-
path: macos-clang-sanitizer-install.tar.gz
4643
macos-clang-build-debug:
4744
runs-on: macOS-latest
4845
steps:
@@ -77,13 +74,10 @@ jobs:
7774
run: |
7875
cmake --build build --target install
7976
- name: Archive installed package
80-
run: |
81-
tar -czvf macos-clang-debug-install.tar.gz -C install .
82-
- name: Upload installed package
83-
uses: actions/upload-artifact@v4
77+
uses: ./.github/actions/archive-install
8478
with:
79+
path: install
8580
name: macos-clang-debug-install
86-
path: macos-clang-debug-install.tar.gz
8781
macos-clang-test:
8882
needs:
8983
- macos-clang-build

.github/workflows/ubuntu.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,10 @@ jobs:
4646
run: |
4747
cmake --build build --target install
4848
- name: Archive installed package
49-
run: |
50-
tar -czvf ubuntu-gcc-install-${{ matrix.os }}.tar.gz -C install .
51-
- name: Upload installed package
52-
uses: actions/upload-artifact@v4
49+
uses: ./.github/actions/archive-install
5350
with:
51+
path: install
5452
name: ubuntu-gcc-install-${{ matrix.os }}
55-
path: ubuntu-gcc-install-${{ matrix.os }}.tar.gz
5653
ubuntu-gcc-build-debug:
5754
runs-on: ${{ matrix.os }}
5855
strategy:
@@ -91,13 +88,10 @@ jobs:
9188
run: |
9289
cmake --build build --target install
9390
- name: Archive installed package
94-
run: |
95-
tar -czvf ubuntu-gcc-debug-install-${{ matrix.os }}.tar.gz -C install .
96-
- name: Upload installed package
97-
uses: actions/upload-artifact@v4
91+
uses: ./.github/actions/archive-install
9892
with:
93+
path: install
9994
name: ubuntu-gcc-debug-install-${{ matrix.os }}
100-
path: ubuntu-gcc-debug-install-${{ matrix.os }}.tar.gz
10195
ubuntu-gcc-test:
10296
needs:
10397
- ubuntu-gcc-build
@@ -242,13 +236,10 @@ jobs:
242236
run: |
243237
cmake --build build --target install
244238
- name: Archive installed package
245-
run: |
246-
tar -czvf ubuntu-clang-install-${{ matrix.os }}.tar.gz -C install .
247-
- name: Upload installed package
248-
uses: actions/upload-artifact@v4
239+
uses: ./.github/actions/archive-install
249240
with:
241+
path: install
250242
name: ubuntu-clang-install-${{ matrix.os }}
251-
path: ubuntu-clang-install-${{ matrix.os }}.tar.gz
252243
ubuntu-clang-test:
253244
needs:
254245
- ubuntu-clang-build
@@ -402,13 +393,10 @@ jobs:
402393
run: |
403394
cmake --build build --target install
404395
- name: Archive installed package
405-
run: |
406-
tar -czvf ubuntu-clang-sanitizer-install-${{ matrix.os }}.tar.gz -C install .
407-
- name: Upload installed package
408-
uses: actions/upload-artifact@v4
396+
uses: ./.github/actions/archive-install
409397
with:
398+
path: install
410399
name: ubuntu-clang-sanitizer-install-${{ matrix.os }}
411-
path: ubuntu-clang-sanitizer-install-${{ matrix.os }}.tar.gz
412400
ubuntu-clang-sanitizer-test:
413401
needs:
414402
- ubuntu-clang-sanitizer-build

.github/workflows/windows.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,10 @@ jobs:
4141
run: |
4242
cmake --build build --target install
4343
- name: Archive installed package
44-
run: Compress-Archive -Path install -DestinationPath windows-msvc-install.zip
45-
shell: pwsh
46-
- name: Upload installed package
47-
uses: actions/upload-artifact@v4
44+
uses: ./.github/actions/archive-install
4845
with:
46+
path: install
4947
name: windows-msvc-install
50-
path: windows-msvc-install.zip
5148
windows-msvc-build-debug:
5249
runs-on: windows-latest
5350
defaults:
@@ -87,13 +84,10 @@ jobs:
8784
run: |
8885
cmake --build build --target install
8986
- name: Archive installed package
90-
run: Compress-Archive -Path install -DestinationPath windows-msvc-debug-install.zip
91-
shell: pwsh
92-
- name: Upload installed package
93-
uses: actions/upload-artifact@v4
87+
uses: ./.github/actions/archive-install
9488
with:
89+
path: install
9590
name: windows-msvc-debug-install
96-
path: windows-msvc-debug-install.zip
9791
windows-msvc-test:
9892
needs:
9993
- windows-msvc-build
@@ -249,13 +243,10 @@ jobs:
249243
run: |
250244
cmake --install build
251245
- name: Archive installed package
252-
run: Compress-Archive -Path install -DestinationPath windows-clang-install.zip
253-
shell: pwsh
254-
- name: Upload installed package
255-
uses: actions/upload-artifact@v4
246+
uses: ./.github/actions/archive-install
256247
with:
248+
path: install
257249
name: windows-clang-install
258-
path: windows-clang-install.zip
259250
windows-clang-test:
260251
needs:
261252
- windows-clang-build

0 commit comments

Comments
 (0)