Skip to content

Commit cec214e

Browse files
authored
fix distribution issues (#23)
* Update CI/CD workflows to use Ubuntu 20.04 and enhance artifact installation process * fix windows test execution * Split Unix workflows into Linux and macOS builds and releases allows support for docker based ubunty-20.04 builds * Enhance Linux build workflow: replace 'gh' with 'curl' for artifact download and add 'jq' for JSON parsing * get latest cmake in ubuntu:20.04 * dist fix
1 parent a9a8605 commit cec214e

11 files changed

Lines changed: 408 additions & 67 deletions

.github/workflows/highs-artifacts-linux.yml

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,65 @@ name: Build HiGHS Static Artifacts (Linux)
33
on:
44
workflow_dispatch:
55

6+
permissions:
7+
contents: write
8+
9+
env:
10+
HIGHS_VERSION: v1.12.0
11+
RELEASE_TAG: highs-static-v1.12.0
12+
613
jobs:
7-
placeholder:
8-
runs-on: ubuntu-latest
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+
926
steps:
10-
- name: Placeholder
11-
run: echo "This is a placeholder. Switch to the feature branch to run the actual artifact build."
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-latest
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: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
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 (Modern CMake)
49+
# ---------------------------------------------------------
50+
- name: Install Build Tools
51+
run: |
52+
export DEBIAN_FRONTEND=noninteractive
53+
export TZ=Etc/UTC
54+
apt-get update
55+
56+
# Install python3-pip to get modern CMake, remove old cmake from apt
57+
apt-get install -y python3-pip g++ git curl jq build-essential zip unzip
58+
59+
# Install latest CMake (3.20+) via pip to support FetchContent features
60+
pip3 install cmake
61+
62+
# Verify version (Should be 3.2x or higher)
63+
cmake --version
64+
65+
# ---------------------------------------------------------
66+
# Checkout repo with submodules
67+
# ---------------------------------------------------------
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
with:
71+
submodules: true
72+
fetch-depth: 0
73+
74+
# ---------------------------------------------------------
75+
# Download Pre-built HiGHS
76+
# ---------------------------------------------------------
77+
- name: Determine Artifact Name
78+
id: artifact
79+
run: |
80+
if [ "${{ inputs.platform }}" = "linux" ] && [ "${{ inputs.arch }}" = "x64" ]; then
81+
echo "zip_name=highs-v1.12.0-linux-x64.zip" >> "$GITHUB_OUTPUT"
82+
else
83+
echo "Error: Unsupported Platform/Arch combination: ${{ inputs.platform }} ${{ inputs.arch }}"
84+
exit 1
85+
fi
86+
87+
# No gh on Ubuntu:20.04 container so use curl
88+
- name: Download HiGHS Artifact
89+
env:
90+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
run: |
92+
mkdir -p ${{ env.HIGHS_DIR }}
93+
echo "Resolving asset URL for ${{ steps.artifact.outputs.zip_name }}..."
94+
RELEASE_JSON=$(curl -sSL -H "Authorization: Bearer $GH_TOKEN" \
95+
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.HIGHS_TAG }}")
96+
ASSET_URL=$(echo "$RELEASE_JSON" | jq -r \
97+
--arg NAME "${{ steps.artifact.outputs.zip_name }}" \
98+
'.assets[] | select(.name == $NAME) | .url')
99+
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then
100+
echo "Error: Could not find asset ${{ steps.artifact.outputs.zip_name }} in release ${{ env.HIGHS_TAG }}"
101+
echo "$RELEASE_JSON" | jq -r '.assets[].name' || true
102+
exit 1
103+
fi
104+
echo "Downloading ${{ steps.artifact.outputs.zip_name }}..."
105+
curl -sSL -H "Authorization: Bearer $GH_TOKEN" \
106+
-H "Accept: application/octet-stream" \
107+
-o "${{ env.HIGHS_DIR }}/highs.zip" "$ASSET_URL"
108+
109+
unzip "${{ env.HIGHS_DIR }}/highs.zip" -d ${{ env.HIGHS_DIR }}
110+
111+
# ---------------------------------------------------------
112+
# Build
113+
# ---------------------------------------------------------
114+
- name: Configure CMake
115+
run: |
116+
cmake -B build \
117+
-DCMAKE_BUILD_TYPE=Release \
118+
-DCMAKE_PREFIX_PATH="${{ env.HIGHS_DIR }}" \
119+
-DBUILD_SHARED_LIBS=OFF
120+
121+
- name: Build Project
122+
run: cmake --build build --config Release
123+
124+
- name: Build Tests
125+
run: cmake --build build --config Release --target solver_tests
126+
127+
- name: Run Tests
128+
run: ctest --test-dir build --output-on-failure -C Release
129+
130+
# ---------------------------------------------------------
131+
# Install (Stage Files)
132+
# ---------------------------------------------------------
133+
- name: Stage Artifacts
134+
run: cmake --install build --config Release --prefix dist
135+
136+
# ---------------------------------------------------------
137+
# Package binaries
138+
# ---------------------------------------------------------
139+
140+
- name: Sanitize Inputs
141+
run: |
142+
# Function to lowercase and replace invalid chars with _
143+
sanitize() {
144+
echo "$1" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/_/g'
145+
}
146+
147+
echo "SAFE_VERSION=$(sanitize "${{ inputs.version }}")" >> $GITHUB_ENV
148+
echo "SAFE_PLATFORM=$(sanitize "${{ inputs.platform }}")" >> $GITHUB_ENV
149+
echo "SAFE_ARCH=$(sanitize "${{ inputs.arch }}")" >> $GITHUB_ENV
150+
151+
- name: Set Asset Name
152+
run: echo "ASSET_NAME=jres-solver-${{ env.SAFE_VERSION }}-${{ env.SAFE_PLATFORM }}-${{ env.SAFE_ARCH }}.${{ inputs.asset_ext }}" >> $GITHUB_ENV
153+
154+
- name: Package (tar.gz)
155+
run: |
156+
# Archive the entire 'dist' folder content (bin, include, lib)
157+
cd dist
158+
tar -czvf "../${{ env.ASSET_NAME }}" .
159+
160+
# ---------------------------------------------------------
161+
# Generate Signature (Checksum)
162+
# ---------------------------------------------------------
163+
- name: Generate Checksum
164+
run: |
165+
# Generate SHA256 checksum for the tarball
166+
shasum -a 256 ${{ env.ASSET_NAME }} > ${{ env.ASSET_NAME }}.sha256
167+
cat ${{ env.ASSET_NAME }}.sha256
168+
169+
# ---------------------------------------------------------
170+
# Upload Artifacts
171+
# ---------------------------------------------------------
172+
- name: Upload Release Asset (Binary)
173+
if: inputs.upload_assets == true
174+
uses: actions/upload-release-asset@v1
175+
env:
176+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177+
with:
178+
upload_url: ${{ inputs.upload_url }}
179+
asset_path: ./${{ env.ASSET_NAME }}
180+
asset_name: ${{ env.ASSET_NAME }}
181+
asset_content_type: application/gzip
182+
183+
- name: Upload Release Asset (Checksum)
184+
if: inputs.upload_assets == true
185+
uses: actions/upload-release-asset@v1
186+
env:
187+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188+
with:
189+
upload_url: ${{ inputs.upload_url }}
190+
asset_path: ./${{ env.ASSET_NAME }}.sha256
191+
asset_name: ${{ env.ASSET_NAME }}.sha256
192+
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 }}

0 commit comments

Comments
 (0)