Skip to content

Commit dc965ac

Browse files
committed
Split Unix workflows into Linux and macOS builds and releases
allows support for docker based ubunty-20.04 builds
1 parent 7fb4a07 commit dc965ac

8 files changed

Lines changed: 310 additions & 30 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build HiGHS Static Artifacts (Linux)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
env:
10+
HIGHS_VERSION: v1.12.0
11+
RELEASE_TAG: highs-static-v1.12.0
12+
13+
jobs:
14+
build-highs:
15+
name: Build ${{ matrix.platform_name }}
16+
runs-on: ubuntu-latest # Use the fast runner...
17+
container: ubuntu:20.04 # ...but build inside the old OS environment
18+
19+
strategy:
20+
matrix:
21+
include:
22+
- arch: x64
23+
platform_name: linux-x64
24+
cmake_args: "-DOPENMP=OFF"
25+
26+
steps:
27+
- name: Install Build Tools
28+
run: |
29+
export DEBIAN_FRONTEND=noninteractive
30+
export TZ=Etc/UTC
31+
apt-get update
32+
apt-get install -y cmake g++ git curl build-essential zip unzip
33+
34+
- name: Checkout HiGHS
35+
uses: actions/checkout@v4
36+
with:
37+
repository: ERGO-Code/HiGHS
38+
ref: ${{ env.HIGHS_VERSION }}
39+
40+
- name: Configure CMake
41+
run: |
42+
cmake -B build \
43+
-DFAST_BUILD=ON \
44+
-DBUILD_SHARED_LIBS=OFF \
45+
-DCMAKE_INSTALL_PREFIX="install" \
46+
-DCMAKE_BUILD_TYPE=Release \
47+
${{ matrix.cmake_args }}
48+
49+
- name: Build & Install
50+
run: |
51+
cmake --build build --config Release --parallel 4
52+
cmake --install build --config Release
53+
54+
- name: Zip Artifacts
55+
run: |
56+
zipName="highs-${{ env.HIGHS_VERSION }}-${{ matrix.platform_name }}.zip"
57+
cd install
58+
zip -r "../$zipName" .
59+
echo "ARTIFACT_NAME=$zipName" >> $GITHUB_ENV
60+
61+
- name: Upload to Release
62+
uses: softprops/action-gh-release@v1
63+
with:
64+
tag_name: ${{ env.RELEASE_TAG }}
65+
files: ${{ env.ARTIFACT_NAME }}
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/highs-artifacts.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build HiGHS Static Artifacts
1+
name: Build HiGHS Static Artifacts (MacOS & Windows)
22

33
on:
44
workflow_dispatch:
@@ -17,10 +17,6 @@ jobs:
1717
strategy:
1818
matrix:
1919
include:
20-
- os: ubuntu-20.04
21-
arch: x64
22-
platform_name: linux-x64
23-
cmake_args: "-DOPENMP=OFF"
2420
- os: macos-13
2521
arch: x64
2622
platform_name: macos-x64

.github/workflows/linux-build.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Linux [reusable] Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
type: string
8+
required: true
9+
name:
10+
type: string
11+
required: true
12+
platform:
13+
type: string
14+
required: true
15+
arch:
16+
type: string
17+
required: true
18+
asset_ext:
19+
type: string
20+
required: true
21+
upload_assets:
22+
type: boolean
23+
required: true
24+
upload_url:
25+
type: string
26+
required: false
27+
28+
jobs:
29+
build:
30+
runs-on: ubuntu-latest
31+
container: ubuntu:20.04
32+
33+
env:
34+
HIGHS_TAG: highs-static-v1.12.0
35+
HIGHS_DIR: ${{ github.workspace }}/highs
36+
37+
steps:
38+
# ---------------------------------------------------------
39+
# Debug Info
40+
# ---------------------------------------------------------
41+
- name: Print Build Info
42+
run: |
43+
echo "Version: ${{ inputs.version }}"
44+
echo "Platform: ${{ inputs.platform }}"
45+
echo "Arch: ${{ inputs.arch }}"
46+
47+
# ---------------------------------------------------------
48+
# Install Build Tools
49+
# ---------------------------------------------------------
50+
- name: Install Build Tools
51+
run: |
52+
export DEBIAN_FRONTEND=noninteractive
53+
export TZ=Etc/UTC
54+
apt-get update
55+
apt-get install -y cmake g++ git curl build-essential zip unzip
56+
57+
# ---------------------------------------------------------
58+
# Checkout repo with submodules
59+
# ---------------------------------------------------------
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
with:
63+
submodules: true
64+
fetch-depth: 0
65+
66+
# ---------------------------------------------------------
67+
# Download Pre-built HiGHS
68+
# ---------------------------------------------------------
69+
- name: Determine Artifact Name
70+
id: artifact
71+
run: |
72+
if [[ "${{ inputs.platform }}" == "linux" && "${{ inputs.arch }}" == "x64" ]]; then
73+
echo "zip_name=highs-v1.12.0-linux-x64.zip" >> $GITHUB_OUTPUT
74+
else
75+
echo "Error: Unsupported Platform/Arch combination: ${{ inputs.platform }} ${{ inputs.arch }}"
76+
exit 1
77+
fi
78+
79+
- name: Download HiGHS Artifact
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
mkdir -p ${{ env.HIGHS_DIR }}
84+
echo "Downloading ${{ steps.artifact.outputs.zip_name }}..."
85+
gh release download ${{ env.HIGHS_TAG }} \
86+
--pattern ${{ steps.artifact.outputs.zip_name }} \
87+
--output "${{ env.HIGHS_DIR }}/highs.zip" \
88+
--repo ${{ github.repository }}
89+
90+
unzip "${{ env.HIGHS_DIR }}/highs.zip" -d ${{ env.HIGHS_DIR }}
91+
92+
# ---------------------------------------------------------
93+
# Build
94+
# ---------------------------------------------------------
95+
- name: Configure CMake
96+
run: |
97+
cmake -B build \
98+
-DCMAKE_BUILD_TYPE=Release \
99+
-DCMAKE_PREFIX_PATH="${{ env.HIGHS_DIR }}" \
100+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/dist" \
101+
-DBUILD_SHARED_LIBS=OFF
102+
103+
- name: Build Project
104+
run: cmake --build build --config Release
105+
106+
- name: Build Tests
107+
run: cmake --build build --config Release --target solver_tests
108+
109+
- name: Run Tests
110+
run: ctest --test-dir build --output-on-failure -C Release
111+
112+
# ---------------------------------------------------------
113+
# Install (Stage Files)
114+
# ---------------------------------------------------------
115+
- name: Stage Artifacts
116+
run: cmake --install build --config Release
117+
118+
# ---------------------------------------------------------
119+
# Package binaries
120+
# ---------------------------------------------------------
121+
122+
- name: Sanitize Inputs
123+
run: |
124+
# Function to lowercase and replace invalid chars with _
125+
sanitize() {
126+
echo "$1" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/_/g'
127+
}
128+
129+
echo "SAFE_VERSION=$(sanitize "${{ inputs.version }}")" >> $GITHUB_ENV
130+
echo "SAFE_PLATFORM=$(sanitize "${{ inputs.platform }}")" >> $GITHUB_ENV
131+
echo "SAFE_ARCH=$(sanitize "${{ inputs.arch }}")" >> $GITHUB_ENV
132+
133+
- name: Set Asset Name
134+
run: echo "ASSET_NAME=jres-solver-${{ env.SAFE_VERSION }}-${{ env.SAFE_PLATFORM }}-${{ env.SAFE_ARCH }}.${{ inputs.asset_ext }}" >> $GITHUB_ENV
135+
136+
- name: Package (tar.gz)
137+
run: |
138+
# Archive the entire 'dist' folder content (bin, include, lib)
139+
cd dist
140+
tar -czvf "../${{ env.ASSET_NAME }}" .
141+
142+
# ---------------------------------------------------------
143+
# Generate Signature (Checksum)
144+
# ---------------------------------------------------------
145+
- name: Generate Checksum
146+
run: |
147+
# Generate SHA256 checksum for the tarball
148+
shasum -a 256 ${{ env.ASSET_NAME }} > ${{ env.ASSET_NAME }}.sha256
149+
cat ${{ env.ASSET_NAME }}.sha256
150+
151+
# ---------------------------------------------------------
152+
# Upload Artifacts
153+
# ---------------------------------------------------------
154+
- name: Upload Release Asset (Binary)
155+
if: inputs.upload_assets == true
156+
uses: actions/upload-release-asset@v1
157+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
with:
160+
upload_url: ${{ inputs.upload_url }}
161+
asset_path: ./${{ env.ASSET_NAME }}
162+
asset_name: ${{ env.ASSET_NAME }}
163+
asset_content_type: application/gzip
164+
165+
- name: Upload Release Asset (Checksum)
166+
if: inputs.upload_assets == true
167+
uses: actions/upload-release-asset@v1
168+
env:
169+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170+
with:
171+
upload_url: ${{ inputs.upload_url }}
172+
asset_path: ./${{ env.ASSET_NAME }}.sha256
173+
asset_name: ${{ env.ASSET_NAME }}.sha256
174+
asset_content_type: text/plain

.github/workflows/linux-ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Linux CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- '**.cpp'
8+
- '**.hpp'
9+
- '**/CMakeLists.txt'
10+
- '.github/workflows/linux-*.yml'
11+
pull_request:
12+
branches: [ "main" ]
13+
paths:
14+
- '**.cpp'
15+
- '**.hpp'
16+
- '**/CMakeLists.txt'
17+
- '.github/workflows/linux-*.yml'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
linux:
24+
uses: ./.github/workflows/linux-build.yml
25+
secrets: inherit
26+
with:
27+
name: "Linux (x64)"
28+
version: ${{ github.ref_name }}
29+
platform: "linux"
30+
arch: x64
31+
asset_ext: tar.gz
32+
upload_assets: false
33+
upload_url: ""
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Linux Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build-all:
12+
strategy:
13+
matrix:
14+
include:
15+
- { name: "Linux (x64)", platform: linux, os: ubuntu-20.04, arch: x64, asset_ext: tar.gz }
16+
17+
uses: ./.github/workflows/linux-build.yml
18+
secrets: inherit
19+
with:
20+
version: ${{ github.ref_name }}
21+
name: ${{ matrix.name }}
22+
platform: ${{ matrix.platform }}
23+
arch: ${{ matrix.arch }}
24+
asset_ext: ${{ matrix.asset_ext }}
25+
upload_assets: true
26+
upload_url: ${{ github.event.release.upload_url }}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unix [reusable] Build
1+
name: MacOS [reusable] Build
22

33
on:
44
workflow_call:
@@ -61,9 +61,7 @@ jobs:
6161
- name: Determine Artifact Name
6262
id: artifact
6363
run: |
64-
if [[ "${{ inputs.platform }}" == "linux" && "${{ inputs.arch }}" == "x64" ]]; then
65-
echo "zip_name=highs-v1.12.0-linux-x64.zip" >> $GITHUB_OUTPUT
66-
elif [[ "${{ inputs.platform }}" == "darwin" && "${{ inputs.arch }}" == "x64" ]]; then
64+
if [[ "${{ inputs.platform }}" == "darwin" && "${{ inputs.arch }}" == "x64" ]]; then
6765
echo "zip_name=highs-v1.12.0-macos-x64.zip" >> $GITHUB_OUTPUT
6866
elif [[ "${{ inputs.platform }}" == "darwin" && "${{ inputs.arch }}" == "arm64" ]]; then
6967
echo "zip_name=highs-v1.12.0-macos-arm64.zip" >> $GITHUB_OUTPUT
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unix CI
1+
name: MacOS CI
22

33
on:
44
push:
@@ -7,34 +7,21 @@ on:
77
- '**.cpp'
88
- '**.hpp'
99
- '**/CMakeLists.txt'
10-
- '.github/workflows/unix-*.yml'
10+
- '.github/workflows/macos*.yml'
1111
pull_request:
1212
branches: [ "main" ]
1313
paths:
1414
- '**.cpp'
1515
- '**.hpp'
1616
- '**/CMakeLists.txt'
17-
- '.github/workflows/unix-*.yml'
17+
- '.github/workflows/macos*.yml'
1818

1919
permissions:
2020
contents: read
2121

2222
jobs:
23-
linux:
24-
uses: ./.github/workflows/unix-build.yml
25-
secrets: inherit
26-
with:
27-
name: "Linux (x64)"
28-
version: ${{ github.ref_name }}
29-
platform: "linux"
30-
os: ubuntu-20.04
31-
arch: x64
32-
asset_ext: tar.gz
33-
upload_assets: false
34-
upload_url: ""
35-
3623
macos-intel:
37-
uses: ./.github/workflows/unix-build.yml
24+
uses: ./.github/workflows/macos-build.yml
3825
secrets: inherit
3926
with:
4027
name: "macOS Intel (x64)"
@@ -47,7 +34,7 @@ jobs:
4734
upload_url: ""
4835

4936
macos-arm:
50-
uses: ./.github/workflows/unix-build.yml
37+
uses: ./.github/workflows/macos-build.yml
5138
secrets: inherit
5239
with:
5340
name: "macOS Apple Silicon (arm64)"

0 commit comments

Comments
 (0)