Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 3fbfa9f

Browse files
authored
Merge pull request #109 from bbc/philipn-gha-source-release-from-linux
Build release on Ubuntu and use source release from Ubuntu
2 parents 5da66e0 + d0da4ac commit 3fbfa9f

File tree

2 files changed

+117
-25
lines changed

2 files changed

+117
-25
lines changed

.github/workflows/release.yml

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ name: Release
22
on:
33
workflow_dispatch:
44
jobs:
5+
source_release:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
12+
13+
- name: Source release
14+
shell: bash
15+
working-directory: ../
16+
run: |
17+
cmake -P bmx/release/source_release.cmake
18+
19+
# actions/upload-artifact doesn't allow . and .. in paths
20+
- name: Move source artefacts into working directory
21+
shell: bash
22+
run: |
23+
mv ../source_release .
24+
25+
- name: Upload source release
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: source-release
29+
path: |
30+
source_release/*.zip
31+
source_release/*.tar.gz
32+
533
binary_release:
634
strategy:
735
fail-fast: false
@@ -11,66 +39,77 @@ jobs:
1139
os: windows-2019
1240
- name: macos-xcode-universal
1341
os: macos-13
42+
- name: ubuntu
43+
os: ubuntu-latest
1444

1545
runs-on: ${{ matrix.os }}
46+
needs: source_release
1647

1748
steps:
49+
- name: Install dependencies (ubuntu)
50+
if: ${{ contains(matrix.os, 'ubuntu') }}
51+
shell: bash
52+
run: |
53+
sudo apt-get -y update
54+
sudo apt-get -y install \
55+
git \
56+
pkg-config \
57+
g++ \
58+
gcc \
59+
cmake \
60+
uuid-dev \
61+
libcurl4-openssl-dev
62+
1863
- uses: maxim-lobanov/setup-xcode@v1
1964
if: ${{ contains(matrix.name, 'xcode') }}
2065
with:
2166
xcode-version: latest-stable
2267

23-
- uses: actions/checkout@v4
68+
- uses: actions/download-artifact@v4
2469
with:
25-
fetch-depth: 0
26-
27-
- name: Source release
28-
shell: bash
29-
working-directory: ../
30-
run: |
31-
cmake -P bmx/release/source_release.cmake
70+
name: source-release
3271

3372
- name: Win64 binary release
3473
if: ${{ contains(matrix.name, 'windows') }}
3574
shell: bash
36-
working-directory: ../
3775
run: |
3876
mkdir binary_release
3977
cd binary_release
40-
unzip -q ../source_release/bmx-*.zip
78+
unzip -q ../bmx-*.zip
4179
cd bmx-*
4280
cmake -P release/win64_binary_release.cmake
4381
4482
- name: MacOS Universal binary release
4583
if: ${{ contains(matrix.os, 'macos') }}
4684
shell: bash
47-
working-directory: ../
4885
run: |
4986
mkdir binary_release
5087
cd binary_release
51-
unzip -q ../source_release/bmx-*.zip
88+
unzip -q ../bmx-*.zip
5289
cd bmx-*
5390
cmake -P release/macos_universal_binary_release.cmake
5491
55-
# actions/upload-artifact doesn't allow . and .. in paths
56-
- name: Move artefacts into working directory
92+
- name: Ubuntu binary build (build only, no artefacts)
93+
if: ${{ contains(matrix.os, 'ubuntu') }}
5794
shell: bash
5895
run: |
59-
mv ../source_release .
60-
mv ../binary_release/bmx-*/out/package ./binary_release
96+
mkdir binary_release
97+
cd binary_release
98+
tar -xzf ../bmx-*.tar.gz
99+
cd bmx-*
100+
cmake -P release/ubuntu_binary_release_build_only.cmake
61101
62-
- name: Upload source release
63-
if: ${{ contains(matrix.name, 'windows') }}
64-
uses: actions/upload-artifact@v4
65-
with:
66-
name: source-release
67-
path: |
68-
source_release/*.zip
69-
source_release/*.tar.gz
102+
# actions/upload-artifact doesn't allow . and .. in paths
103+
- name: Move binary artefacts into binary_release directory
104+
if: ${{ !contains(matrix.os, 'ubuntu') }}
105+
shell: bash
106+
run: |
107+
mv binary_release/bmx-*/out/package/bmx-*.zip ./binary_release
70108
71109
- name: Upload binary release
110+
if: ${{ !contains(matrix.os, 'ubuntu') }}
72111
uses: actions/upload-artifact@v4
73112
with:
74113
name: binary-release-${{ matrix.name }}
75114
path: |
76-
binary_release/*.zip
115+
binary_release/bmx-*.zip
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Build bmx on Ubuntu using the source release.
2+
3+
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
4+
5+
if(NOT DEFINED BMX_BRANCH)
6+
set(BMX_BRANCH main)
7+
endif()
8+
if(NOT DEFINED USE_GIT_CLONE)
9+
set(USE_GIT_CLONE OFF)
10+
endif()
11+
12+
include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
13+
14+
15+
function(copy_and_rename_file source dest)
16+
get_filename_component(dest_dir ${dest} DIRECTORY)
17+
get_filename_component(source_name ${source} NAME)
18+
file(COPY ${source} DESTINATION ${dest_dir})
19+
file(RENAME ${dest_dir}/${source_name} ${dest})
20+
endfunction()
21+
22+
23+
if(USE_GIT_CLONE)
24+
# Clone bmx
25+
set(bmx_dir "${CMAKE_CURRENT_BINARY_DIR}/bmx")
26+
if(EXISTS ${bmx_dir})
27+
message(FATAL_ERROR "Can't continue with clean release as 'bmx' directory already exists")
28+
endif()
29+
run_command("${CMAKE_CURRENT_BINARY_DIR}" git clone https://github.com/bbc/bmx.git)
30+
run_command("${bmx_dir}" git checkout ${BMX_BRANCH})
31+
else()
32+
get_filename_component(bmx_dir "${CMAKE_CURRENT_LIST_DIR}/.." REALPATH)
33+
if(EXISTS ${bmx_dir}/out)
34+
message(FATAL_ERROR "Can't continue with clean release as 'out' sub-directory already exists")
35+
endif()
36+
endif()
37+
38+
# Create build, install and package directories
39+
set(build_dir "${bmx_dir}/out/build")
40+
file(MAKE_DIRECTORY ${build_dir})
41+
set(install_dir "${bmx_dir}/out/install")
42+
file(MAKE_DIRECTORY ${install_dir})
43+
44+
extract_version("${bmx_dir}/CMakeLists.txt" bmx_version)
45+
set(package_dir "${bmx_dir}/out/package")
46+
set(bmx_package_dir "${package_dir}/bmx-ubuntu-binary-${bmx_version}")
47+
file(MAKE_DIRECTORY ${bmx_package_dir})
48+
49+
# Configure, build, test and install
50+
run_command("${build_dir}" cmake -DCMAKE_INSTALL_PREFIX=../install -DBMX_BUILD_URIPARSER_SOURCE=ON -DBMX_BUILD_EXPAT_SOURCE=ON -DBMX_BUILD_WITH_LIBCURL=ON -DCMAKE_BUILD_TYPE=Release ../../)
51+
run_command("${build_dir}" cmake --build .)
52+
run_command("${build_dir}" ctest --output-on-failure)
53+
run_command("${build_dir}" cmake --build . --target install)

0 commit comments

Comments
 (0)