Skip to content

Commit 1081143

Browse files
committed
Introduce and switch to CPack release workflow
1 parent 31261d8 commit 1081143

File tree

4 files changed

+246
-55
lines changed

4 files changed

+246
-55
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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+
CMAKE_BUILD_TYPE: ${{ inputs.build-type }}
38+
CMAKE_FLAGS: ${{ inputs.extra-cmake-flags }}
39+
40+
jobs:
41+
linux:
42+
name: Linux packages
43+
runs-on: ubuntu-22.04
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Build packages
48+
run: make build-package
49+
50+
- name: Collect artifacts
51+
run: |
52+
set -euo pipefail
53+
shopt -s nullglob
54+
mkdir -p artifacts/linux
55+
for file in build/*.deb build/*.rpm; do
56+
cp "$file" artifacts/linux/
57+
done
58+
59+
- uses: actions/upload-artifact@v4
60+
if: inputs.save-artifacts
61+
with:
62+
name: linux-packages
63+
path: artifacts/linux
64+
retention-days: 7
65+
66+
macos:
67+
name: macOS packages
68+
runs-on: macos-13
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Build packages
73+
run: make build-package
74+
75+
- name: Collect artifacts
76+
run: |
77+
set -euo pipefail
78+
shopt -s nullglob
79+
mkdir -p artifacts/macos
80+
for file in build/*.pkg build/*.dmg; do
81+
cp "$file" artifacts/macos/
82+
done
83+
84+
- uses: actions/upload-artifact@v4
85+
if: inputs.save-artifacts
86+
with:
87+
name: macos-packages
88+
path: artifacts/macos
89+
retention-days: 7
90+
91+
windows:
92+
name: Windows packages
93+
runs-on: windows-2022
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- name: Add WiX to PATH
98+
shell: pwsh
99+
run: |
100+
$wixPath = "C:\\Program Files (x86)\\WiX Toolset v3.11\\bin"
101+
if (Test-Path $wixPath) { Add-Content -Path $env:GITHUB_PATH -Value $wixPath }
102+
103+
- name: Install OpenSSL
104+
shell: pwsh
105+
run: |
106+
choco install openssl.light --no-progress -y
107+
$opensslRoot = "C:\\Program Files\\OpenSSL-Win64"
108+
if (-not (Test-Path $opensslRoot)) {
109+
$opensslRoot = "C:\\Program Files\\OpenSSL"
110+
}
111+
if (-not (Test-Path $opensslRoot)) {
112+
throw "OpenSSL installation path not found"
113+
}
114+
$libPath = Join-Path $opensslRoot "lib"
115+
$vcLibPath = Join-Path $libPath "VC\\x64"
116+
if (Test-Path $vcLibPath) {
117+
$libPath = $vcLibPath
118+
}
119+
"OPENSSL_DIR=$opensslRoot" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
120+
"OPENSSL_ROOT_DIR=$opensslRoot" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
121+
"OPENSSL_LIB_DIR=$libPath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
122+
"OPENSSL_INCLUDE_DIR=$(Join-Path $opensslRoot 'include')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
123+
124+
- name: Configure
125+
shell: pwsh
126+
run: |
127+
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }}
128+
129+
- name: Build
130+
shell: pwsh
131+
run: cmake --build build --config ${{ inputs.build-type }}
132+
133+
- name: Package (MSI)
134+
shell: pwsh
135+
working-directory: build
136+
run: cpack -G WIX -C ${{ inputs.build-type }}
137+
138+
- name: Collect artifacts
139+
if: inputs.save-artifacts
140+
shell: pwsh
141+
run: |
142+
New-Item -ItemType Directory -Path artifacts\windows -Force | Out-Null
143+
Get-ChildItem build -Filter *.msi | Copy-Item -Destination artifacts\windows
144+
145+
- uses: actions/upload-artifact@v4
146+
if: inputs.save-artifacts
147+
with:
148+
name: windows-packages
149+
path: artifacts/windows
150+
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

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
EMPTY :=
22
SPACE := ${EMPTY} ${EMPTY}
3+
OS_TYPE := $(shell uname -s)
34

45
ifndef SCYLLA_TEST_FILTER
56
SCYLLA_TEST_FILTER := $(subst ${SPACE},${EMPTY},ClusterTests.*\
@@ -181,6 +182,15 @@ FULL_RUSTFLAGS := --cfg cpp_rust_unstable --cfg cpp_integration_testing
181182
CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
182183
BUILD_DIR := "${CURRENT_DIR}build"
183184
INTEGRATION_TEST_BIN := ${BUILD_DIR}/cassandra-integration-tests
185+
CMAKE_FLAGS ?=
186+
CMAKE_BUILD_TYPE ?= Release
187+
CMAKE_INSTALL_PREFIX ?= /usr
188+
189+
ifeq ($(OS_TYPE),Darwin)
190+
CPACK_GENERATORS ?= DragNDrop productbuild
191+
else
192+
CPACK_GENERATORS ?= DEB RPM
193+
endif
184194

185195
clean:
186196
rm -rf "${BUILD_DIR}"
@@ -260,6 +270,32 @@ build-examples:
260270
cmake -DCASS_BUILD_INTEGRATION_TESTS=off -DCASS_BUILD_EXAMPLES=on -DCMAKE_BUILD_TYPE=Release .. && (make -j 4 || make);\
261271
}
262272

273+
.ubuntu-package-install-dependencies: update-apt-cache-if-needed
274+
sudo apt-get install -y rpm ninja-build pkg-config
275+
276+
.package-build-prepare:
277+
@missing=""; \
278+
for bin in ninja rpmbuild pkg-config; do \
279+
if ! command -v $$bin >/dev/null 2>&1; then \
280+
missing="$$missing $$bin"; \
281+
fi; \
282+
done; \
283+
if [ -n "$$missing" ]; then \
284+
$(MAKE) .ubuntu-package-install-dependencies; \
285+
fi
286+
287+
.package-configure: .package-build-prepare
288+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX) $(CMAKE_FLAGS)
289+
# cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} ${{ inputs.extra-cmake-flags }}
290+
291+
build-driver: .package-configure
292+
cmake --build build --config $(CMAKE_BUILD_TYPE)
293+
294+
build-package: build-driver
295+
@cd build; for gen in $(CPACK_GENERATORS); do \
296+
cpack -G $${gen} -C $(CMAKE_BUILD_TYPE); \
297+
done
298+
263299
_update-rust-tooling:
264300
@echo "Run rustup update"
265301
@rustup update

0 commit comments

Comments
 (0)