Skip to content

Commit c5ef443

Browse files
committed
Introduce and switch to CPack release workflow
1 parent d3be384 commit c5ef443

File tree

3 files changed

+231
-55
lines changed

3 files changed

+231
-55
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Build CPack Packages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-type:
7+
description: CMake build type used for packaging
8+
type: string
9+
default: Release
10+
extra-cmake-flags:
11+
description: Additional flags passed to CMake configure step
12+
type: string
13+
default: ""
14+
save-artifacts:
15+
description: Save built packages as artifacts
16+
type: boolean
17+
default: false
18+
secrets: {}
19+
workflow_dispatch:
20+
inputs:
21+
build-type:
22+
description: CMake build type used for packaging
23+
type: string
24+
default: Release
25+
extra-cmake-flags:
26+
description: Additional flags passed to CMake configure step
27+
type: string
28+
default: ""
29+
save-artifacts:
30+
description: Save built packages as artifacts
31+
type: boolean
32+
default: false
33+
secrets: {}
34+
35+
env:
36+
CARGO_TERM_COLOR: always
37+
38+
jobs:
39+
linux:
40+
name: Linux packages
41+
runs-on: ubuntu-22.04
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Install tooling
46+
run: |
47+
sudo apt-get update
48+
sudo apt-get install -y rpm ninja-build
49+
50+
- name: Configure
51+
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }}
52+
53+
- name: Build
54+
run: cmake --build build --config ${{ inputs.build-type }}
55+
56+
- name: Package (DEB and RPM)
57+
working-directory: build
58+
run: |
59+
cpack -G DEB -C ${{ inputs.build-type }}
60+
cpack -G RPM -C ${{ inputs.build-type }}
61+
62+
- name: Collect artifacts
63+
run: |
64+
set -euo pipefail
65+
shopt -s nullglob
66+
mkdir -p artifacts/linux
67+
for file in build/*.deb build/*.rpm; do
68+
cp "$file" artifacts/linux/
69+
done
70+
71+
- uses: actions/upload-artifact@v4
72+
if: inputs.save-artifacts
73+
with:
74+
name: linux-packages
75+
path: artifacts/linux
76+
retention-days: 7
77+
78+
macos:
79+
name: macOS packages
80+
runs-on: macos-13
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: Configure
85+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }}
86+
87+
- name: Build
88+
run: cmake --build build --config ${{ inputs.build-type }}
89+
90+
- name: Package (pkg and dmg)
91+
working-directory: build
92+
run: |
93+
cpack -G productbuild -C ${{ inputs.build-type }}
94+
cpack -G DragNDrop -C ${{ inputs.build-type }}
95+
96+
- name: Collect artifacts
97+
run: |
98+
set -euo pipefail
99+
shopt -s nullglob
100+
mkdir -p artifacts/macos
101+
for file in build/*.pkg build/*.dmg; do
102+
cp "$file" artifacts/macos/
103+
done
104+
105+
- uses: actions/upload-artifact@v4
106+
if: inputs.save-artifacts
107+
with:
108+
name: macos-packages
109+
path: artifacts/macos
110+
retention-days: 7
111+
112+
windows:
113+
name: Windows packages
114+
runs-on: windows-2022
115+
steps:
116+
- uses: actions/checkout@v4
117+
118+
- name: Add WiX to PATH
119+
shell: pwsh
120+
run: |
121+
$wixPath = "C:\\Program Files (x86)\\WiX Toolset v3.11\\bin"
122+
if (Test-Path $wixPath) { Add-Content -Path $env:GITHUB_PATH -Value $wixPath }
123+
124+
- name: Install OpenSSL
125+
shell: pwsh
126+
run: |
127+
choco install openssl.light --no-progress -y
128+
$opensslRoot = "C:\\Program Files\\OpenSSL-Win64"
129+
if (-not (Test-Path $opensslRoot)) {
130+
$opensslRoot = "C:\\Program Files\\OpenSSL"
131+
}
132+
if (-not (Test-Path $opensslRoot)) {
133+
throw "OpenSSL installation path not found"
134+
}
135+
$libPath = Join-Path $opensslRoot "lib"
136+
$vcLibPath = Join-Path $libPath "VC\\x64"
137+
if (Test-Path $vcLibPath) {
138+
$libPath = $vcLibPath
139+
}
140+
"OPENSSL_DIR=$opensslRoot" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
141+
"OPENSSL_ROOT_DIR=$opensslRoot" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
142+
"OPENSSL_LIB_DIR=$libPath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
143+
"OPENSSL_INCLUDE_DIR=$(Join-Path $opensslRoot 'include')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
144+
145+
- name: Configure
146+
shell: pwsh
147+
run: |
148+
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }}
149+
150+
- name: Build
151+
shell: pwsh
152+
run: cmake --build build --config ${{ inputs.build-type }}
153+
154+
- name: Package (MSI)
155+
shell: pwsh
156+
working-directory: build
157+
run: cpack -G WIX -C ${{ inputs.build-type }}
158+
159+
- name: Collect artifacts
160+
if: inputs.save-artifacts
161+
shell: pwsh
162+
run: |
163+
New-Item -ItemType Directory -Path artifacts\windows -Force | Out-Null
164+
Get-ChildItem build -Filter *.msi | Copy-Item -Destination artifacts\windows
165+
166+
- uses: actions/upload-artifact@v4
167+
if: inputs.save-artifacts
168+
with:
169+
name: windows-packages
170+
path: artifacts/windows
171+
retention-days: 7

.github/workflows/pkg.yml

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,29 @@ name: Build packages
22

33
on:
44
push:
5+
paths-ignore:
6+
- "docs/**"
7+
- ".github/workflows/docs-**"
8+
- ".github/workflows/build-lint-and-test.yml"
9+
- "examples/**"
10+
- "*.md"
511
branches: [ master ]
612
pull_request:
13+
paths-ignore:
14+
- "docs/**"
15+
- ".github/workflows/docs-**"
16+
- ".github/workflows/build-lint-and-test.yml"
17+
- "examples/**"
18+
- "*.md"
719
branches: [ master ]
820

921
env:
1022
CARGO_TERM_COLORS: always
1123

1224
jobs:
13-
build-rpm-pkgs:
14-
name: Build rpm packages
15-
runs-on: ubuntu-22.04
16-
container:
17-
image: fedora:latest
18-
# Required by `mock`:
19-
### INFO: It seems that you run Mock in a Docker container.
20-
### Mock though uses container tooling itself (namely Podman) for downloading bootstrap image.
21-
### This might require you to run Mock in 'docker run --privileged'.
22-
options: --privileged
23-
# It does not seem to be necessary (CI run without it was successful).
24-
# However, without it, there appear some errors during `mock` execution.
25-
# I've found the solution to these errors here: https://github.com/containers/buildah/issues/3666.
26-
# They are related to podman, which is used by `mock` under the hood.
27-
volumes:
28-
- /var/lib/containers:/var/lib/containers
29-
30-
strategy:
31-
matrix:
32-
dist-version: [rocky-9-x86_64, fedora-41-x86_64, fedora-42-x86_64]
33-
fail-fast: false
34-
35-
steps:
36-
# See: https://github.com/actions/checkout/issues/363
37-
# An issue related to GH actions containers
38-
- name: Install git and update safe directory
39-
run: |
40-
dnf update -y
41-
dnf install -y git
42-
git config --global --add safe.directory "$GITHUB_WORKSPACE"
43-
44-
- name: Checkout
45-
uses: actions/checkout@v4
46-
47-
- name: Build rpm package for ${{ matrix.dist-version }}
48-
run: ./dist/redhat/build_rpm.sh --target ${{ matrix.dist-version }}
49-
50-
build-deb-pkgs:
51-
name: Build deb packages
52-
runs-on: ubuntu-22.04
53-
54-
strategy:
55-
matrix:
56-
dist-version: [jammy, noble]
57-
fail-fast: false
58-
59-
steps:
60-
- name: Checkout
61-
uses: actions/checkout@v4
62-
63-
- name: Update apt cache
64-
run: sudo apt-get update -y
65-
66-
- name: Build deb package for ${{ matrix.dist-version }}
67-
run: ./dist/debian/build_deb.sh --target ${{ matrix.dist-version }}
25+
build-packages:
26+
uses: ./.github/workflows/build-cpack-packages.yml
27+
with:
28+
save-artifacts: false
29+
build-type: Release
30+
secrets: inherit
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Attach Packages to Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
release-tag:
9+
description: release tag
10+
type: string
11+
required: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build-packages:
18+
uses: ./.github/workflows/build-cpack-packages.yml
19+
with:
20+
save-artifacts: true
21+
build-type: Release
22+
secrets: inherit
23+
24+
publish:
25+
name: Upload artifacts to release
26+
runs-on: ubuntu-22.04
27+
needs: build-packages
28+
steps:
29+
- uses: actions/download-artifact@v4
30+
with:
31+
path: packages
32+
- name: Upload packages to GitHub Release
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
TAG_NAME: ${{ inputs.release-tag || github.event.release.tag_name }}
36+
run: |
37+
set -euo pipefail
38+
shopt -s nullglob
39+
for file in packages/*/*; do
40+
echo "Uploading $file"
41+
gh release upload "$TAG_NAME" "$file" --clobber
42+
done

0 commit comments

Comments
 (0)