Skip to content

Commit c7c1d50

Browse files
committed
build: release process to specify criu version
1 parent f1266df commit c7c1d50

File tree

4 files changed

+141
-10
lines changed

4 files changed

+141
-10
lines changed

.github/workflows/build.yaml

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@ on:
1919
- synchronize
2020
- reopened
2121

22+
# Manual trigger for custom builds and releases
23+
workflow_dispatch:
24+
inputs:
25+
criu_version:
26+
description: 'CRIU version to build (e.g., 4.1)'
27+
required: false
28+
type: string
29+
criu_commit:
30+
description: 'CRIU commit/tag to build (overrides version if set)'
31+
required: false
32+
type: string
33+
criu_shasum:
34+
description: 'SHA256 checksum for the CRIU source'
35+
required: true
36+
type: string
37+
build_revision:
38+
description: 'Build revision suffix (e.g., r1, r2) for build script changes'
39+
required: false
40+
type: string
41+
release_type:
42+
description: 'Release type'
43+
required: false
44+
type: choice
45+
default: 'draft'
46+
options:
47+
- 'none'
48+
- 'draft'
49+
- 'release'
50+
2251
# avoid running multiple copies of the same workflow in parallel
2352
concurrency:
2453
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -38,6 +67,7 @@ jobs:
3867
uses: docker/setup-buildx-action@v3.10.0
3968

4069
- name: Build criu
70+
if: github.event_name != 'workflow_dispatch'
4171
uses: docker/build-push-action@v6
4272
with:
4373
context: .
@@ -50,6 +80,24 @@ jobs:
5080
cache-from: type=gha,scope=criu-build-image-amd64
5181
cache-to: type=gha,mode=max,scope=criu-build-image-amd64
5282

83+
- name: Build criu
84+
if: github.event_name == 'workflow_dispatch'
85+
uses: docker/build-push-action@v6
86+
with:
87+
context: .
88+
outputs: type=local,dest=./output
89+
file: Dockerfile
90+
push: false
91+
load: true
92+
tags: "criu-build-image-amd64"
93+
platforms: "linux/amd64"
94+
cache-from: type=gha,scope=criu-build-image-amd64
95+
cache-to: type=gha,mode=max,scope=criu-build-image-amd64
96+
build-args: |
97+
CRIU_VERSION=${{ inputs.criu_version }}
98+
CRIU_COMMIT=${{ inputs.criu_commit }}
99+
CRIU_SHASUM=${{ inputs.criu_shasum }}
100+
53101
- name: Upload amd64 artifact
54102
uses: actions/upload-artifact@v4.6.2
55103
with:
@@ -69,6 +117,21 @@ jobs:
69117
uses: docker/setup-buildx-action@v3.10.0
70118

71119
- name: Build criu
120+
if: github.event_name != 'workflow_dispatch'
121+
uses: docker/build-push-action@v6
122+
with:
123+
context: .
124+
outputs: type=local,dest=./output
125+
file: Dockerfile
126+
push: false
127+
load: true
128+
tags: "criu-build-image-arm64"
129+
platforms: "linux/arm64"
130+
cache-from: type=gha,scope=criu-build-image-arm64
131+
cache-to: type=gha,mode=max,scope=criu-build-image-arm64
132+
133+
- name: Build criu
134+
if: github.event_name == 'workflow_dispatch'
72135
uses: docker/build-push-action@v6
73136
with:
74137
context: .
@@ -80,6 +143,10 @@ jobs:
80143
platforms: "linux/arm64"
81144
cache-from: type=gha,scope=criu-build-image-arm64
82145
cache-to: type=gha,mode=max,scope=criu-build-image-arm64
146+
build-args: |
147+
CRIU_VERSION=${{ inputs.criu_version }}
148+
CRIU_COMMIT=${{ inputs.criu_commit }}
149+
CRIU_SHASUM=${{ inputs.criu_shasum }}
83150
84151
- name: Upload arm64 artifact
85152
uses: actions/upload-artifact@v4.6.2
@@ -89,7 +156,7 @@ jobs:
89156

90157
release:
91158
name: Release
92-
if: "contains(github.event.head_commit.message, '[release]') && ( github.event.ref=='refs/heads/master' || contains(github.event.ref, 'release') )"
159+
if: "inputs.release_type != 'none'"
93160
needs: [build-amd64, build-arm64]
94161
runs-on: ubuntu-24.04
95162
permissions:
@@ -103,7 +170,7 @@ jobs:
103170
with:
104171
pattern: criu-amd64
105172
path: dist
106-
173+
107174
- name: Download build artifacts (arm64)
108175
uses: actions/download-artifact@v4.3.0
109176
with:
@@ -115,10 +182,23 @@ jobs:
115182
with:
116183
java-version: 11
117184

118-
- name: Version
185+
- name: Determine version
119186
id: version
120187
run: |
121-
VERSION=$(cmake --preset static-release -LA | grep CRIU_VERSION | cut -d'=' -f2)
188+
if [ -n "${{ inputs.criu_commit }}" ]; then
189+
BASE_VERSION="${{ inputs.criu_commit }}"
190+
elif [ -n "${{ inputs.criu_version }}" ]; then
191+
BASE_VERSION="${{ inputs.criu_version }}"
192+
else
193+
BASE_VERSION=$(cmake --preset static-release -LA | grep CRIU_VERSION | cut -d'=' -f2)
194+
fi
195+
196+
if [ -n "${{ inputs.build_revision }}" ]; then
197+
VERSION="${BASE_VERSION}-${{ inputs.build_revision }}"
198+
else
199+
VERSION="${BASE_VERSION}"
200+
fi
201+
122202
echo "VERSION = $VERSION"
123203
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
124204
@@ -127,3 +207,4 @@ jobs:
127207
env:
128208
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129209
JRELEASER_PROJECT_VERSION: ${{ steps.version.outputs.VERSION }}
210+
JRELEASER_DRAFT: ${{ inputs.release_type == 'draft' }}

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ project(criu-static VERSION 4.1)
44
include(GNUInstallDirs)
55
include(macros/dependencies.cmake)
66

7-
# Upstream CRIU version and SHA256 checksum
8-
set(CRIU_VERSION "${PROJECT_VERSION}" CACHE STRING "CRIU version to build")
9-
set(CRIU_SHASUM "9a3094f3d0aa6cfa8bd5c9b92c05f4a566ad21ee20eb9b2fbc6129a74d1f6dc7")
7+
# CRIU source configuration, specify either version or commit
8+
set(CRIU_VERSION "${PROJECT_VERSION}" CACHE STRING "CRIU version to build (e.g., 4.1)")
9+
set(CRIU_COMMIT "" CACHE STRING "CRIU git commit/tag to build instead of version")
10+
set(CRIU_SHASUM "9a3094f3d0aa6cfa8bd5c9b92c05f4a566ad21ee20eb9b2fbc6129a74d1f6dc7" CACHE STRING "SHA256 checksum for CRIU source")
1011

1112
# Force static building
1213
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries" FORCE)
@@ -83,9 +84,16 @@ set(CRIU_MAKE_VARS
8384
"PREFIX=${CRIU_INSTALL_DIR}"
8485
)
8586

87+
# Build CRIU URL based on commit or version
88+
if(CRIU_COMMIT)
89+
set(CRIU_URL "https://github.com/checkpoint-restore/criu/archive/${CRIU_COMMIT}.tar.gz")
90+
else()
91+
set(CRIU_URL "https://github.com/checkpoint-restore/criu/archive/refs/tags/v${CRIU_VERSION}.tar.gz")
92+
endif()
93+
8694
register_dependency(
8795
criu
88-
"https://github.com/checkpoint-restore/criu/archive/refs/tags/v${CRIU_VERSION}.tar.gz"
96+
"${CRIU_URL}"
8997
"${CRIU_SHASUM}"
9098
"COPYING"
9199
)
@@ -94,7 +102,7 @@ ExternalProject_Add(criu
94102
URL ${DEP_criu_URL}
95103
URL_HASH SHA256=${DEP_criu_SHA256}
96104
UPDATE_DISCONNECTED 1
97-
PATCH_COMMAND patch -p1 -i ${CMAKE_SOURCE_DIR}/patch/criu-build.patch && patch -p1 -i ${CMAKE_SOURCE_DIR}/patch/criu-static-plugin.patch && patch -p1 -i ${CMAKE_SOURCE_DIR}/patch/pagehole-fix.patch
105+
PATCH_COMMAND patch -p1 -i ${CMAKE_SOURCE_DIR}/patch/criu-build.patch && patch -p1 -i ${CMAKE_SOURCE_DIR}/patch/criu-static-plugin.patch
98106
CONFIGURE_COMMAND ""
99107
DOWNLOAD_DIR ${SOURCE_DOWNLOADS_DIR}
100108
DOWNLOAD_NAME ${DEP_criu_FILENAME}

Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
FROM docker.io/alpine:3.22 AS builder
2+
3+
ARG CRIU_VERSION
4+
ARG CRIU_COMMIT
5+
ARG CRIU_SHASUM
6+
27
RUN apk update
38
RUN apk add cmake \
49
make \
@@ -33,7 +38,12 @@ COPY package_deps_licenses.cmake.in /source
3338
COPY check_musl.cmake /source
3439

3540
WORKDIR /source
36-
RUN cmake --preset static-release
41+
42+
RUN cmake --preset static-release \
43+
${CRIU_VERSION:+-DCRIU_VERSION="$CRIU_VERSION"} \
44+
${CRIU_COMMIT:+-DCRIU_COMMIT="$CRIU_COMMIT"} \
45+
${CRIU_SHASUM:+-DCRIU_SHASUM="$CRIU_SHASUM"}
46+
3747
RUN cmake --build --preset static-release
3848
RUN cpack --config build/CPackConfig.cmake --verbose -B dist
3949
RUN rm -Rf dist/_CPack_Packages

RELEASE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Release Instructions
2+
3+
## Creating a Draft Release
4+
5+
1. Go to Actions in this repository
6+
2. Click "Run workflow"
7+
3. Fill in the inputs:
8+
- **CRIU version**: e.g., `4.1` (leave empty to use default)
9+
- **CRIU commit**: e.g., `abc123def` or `master` (overrides version if set)
10+
- **CRIU shasum**: Required SHA256 checksum for the source
11+
- **Build revision**: e.g., `r1`, `r2` (for build script changes, optional)
12+
- **Release type**: Select `draft` (default)
13+
4. Click "Run workflow"
14+
15+
## Promoting Draft to Release
16+
17+
You can also do a release type `release` directly, in that case you don't need to promote a draft.
18+
19+
1. Go to Releases in this repository
20+
2. Find your draft release
21+
3. Click "Edit"
22+
4. Uncheck "Save as draft"
23+
5. Click "Publish release"
24+
25+
## Updating Default CRIU Version
26+
27+
When promoting a CRIU version permanently (not just for testing):
28+
29+
1. Create a PR to update the defaults in `CMakeLists.txt`:
30+
- Update `CRIU_VERSION`
31+
- Update `CRIU_SHASUM`
32+
2. After PR is merged, normal CI builds will use the new version by default, this is important so that PRs will test against the latest release CRIU version we released for.

0 commit comments

Comments
 (0)