Skip to content

Commit 1797009

Browse files
authored
Add build script (#1)
* Fix * Update build.yml * Fix * Fix
1 parent 050a92f commit 1797009

File tree

5 files changed

+206
-1
lines changed

5 files changed

+206
-1
lines changed

.github/workflows/build.yml

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
name: "build"
3+
4+
"on":
5+
push:
6+
branches:
7+
- "main"
8+
tags:
9+
- "*"
10+
pull_request:
11+
branches:
12+
- "main"
13+
14+
concurrency:
15+
group: "${{ github.workflow }}-${{ github.ref }}"
16+
cancel-in-progress: "${{ github.ref != 'refs/heads/main' }}"
17+
18+
env:
19+
CURL_VERSION: "curl-8_7_1"
20+
CURL_BASEURL: "https://github.com/curl/curl/archive/refs/tags"
21+
CURL_TARGZ_SHA256: "0e46c856f517602c347bb5fe5b73174f8ee798bc87f1a97235c95761f75fcc28"
22+
CURL_ZIP_SHA256: "1522999600630964ADC3130EADA47DC0BE2A71908A36944B7AA78AAD2B1006B7"
23+
24+
jobs:
25+
BuildMac:
26+
runs-on: "macos-14"
27+
28+
strategy:
29+
matrix:
30+
config:
31+
- "Release"
32+
- "Debug"
33+
34+
defaults:
35+
run:
36+
shell: "bash"
37+
38+
steps:
39+
- name: "Get version"
40+
run: |
41+
if [[ $GITHUB_REF =~ ^refs/tags/ ]]
42+
then version="${GITHUB_REF#refs/tags/}"
43+
else version=main
44+
fi
45+
printf "version=%s" "$version" > "$GITHUB_OUTPUT"
46+
id: "get-version"
47+
48+
- name: "Checkout"
49+
uses: "actions/checkout@v4"
50+
51+
- name: "Download and extract Curl"
52+
run: |
53+
curl -fsSLO "$CURL_BASEURL/$CURL_VERSION.tar.gz"
54+
echo "$CURL_TARGZ_SHA256 $CURL_VERSION.tar.gz" | shasum -c
55+
tar -xf "$CURL_VERSION.tar.gz"
56+
57+
- name: "Run build-macos.sh"
58+
run: './build-macos.sh ${{ matrix.config }} ${{ steps.get-version.outputs.version }} "curl-$CURL_VERSION"'
59+
60+
- name: "Upload artifacts"
61+
uses: "actions/upload-artifact@v4"
62+
with:
63+
name: "libcurl-macos-${{ matrix.config }}"
64+
path: "release/*.tar.gz"
65+
66+
BuildWindows:
67+
runs-on: "windows-2022"
68+
69+
strategy:
70+
matrix:
71+
config:
72+
- "Release"
73+
- "Debug"
74+
75+
steps:
76+
- name: "Get version"
77+
shell: bash
78+
run: |
79+
if [[ $GITHUB_REF =~ ^refs/tags/ ]]
80+
then version="${GITHUB_REF#refs/tags/}"
81+
else version=main
82+
fi
83+
printf "version=%s" "$version" > "$GITHUB_OUTPUT"
84+
id: "get-version"
85+
86+
- name: "Checkout"
87+
uses: "actions/checkout@v4"
88+
89+
- name: "Download and extract Curl"
90+
run: |
91+
Invoke-WebRequest -Uri "$Env:CURL_BASEURL/$Env:CURL_VERSION.zip" -OutFile "$Env:CURL_VERSION.zip"
92+
$hash = Get-FileHash "$Env:CURL_VERSION.zip" -Algorithm SHA256
93+
if ( $hash.Hash -ne "$Env:CURL_ZIP_SHA256" ) {
94+
exit 1
95+
}
96+
Expand-Archive -Path "$Env:CURL_VERSION.zip" -DestinationPath "."
97+
98+
- name: "Run Build-Windows.ps1"
99+
run: './Build-Windows.ps1 -Configuration "${{ matrix.config }}" -Version "${{ steps.get-version.outputs.version }}" -CurlDirectory "curl-$Env:CURL_VERSION"'
100+
101+
- name: "Upload artifacts"
102+
uses: "actions/upload-artifact@v4"
103+
with:
104+
name: "opencv-windows-${{ matrix.config }}"
105+
path: "release/*.zip"
106+
107+
Release:
108+
runs-on: "ubuntu-22.04"
109+
110+
if: "github.event_name == 'push' && contains(github.ref, 'refs/tags/')"
111+
112+
needs:
113+
- "BuildMac"
114+
- "BuildWindows"
115+
116+
permissions:
117+
contents: "write"
118+
119+
defaults:
120+
run:
121+
shell: "bash"
122+
123+
steps:
124+
- name: "Get version"
125+
shell: "bash"
126+
run: |
127+
if [[ $GITHUB_REF =~ ^refs/tags/ ]]
128+
then version="${GITHUB_REF#refs/tags/}"
129+
else version=main
130+
fi
131+
printf "version=%s" "$version" > "$GITHUB_OUTPUT"
132+
id: "get-version"
133+
134+
- name: "Download build artifacts"
135+
uses: "actions/download-artifact@v4"
136+
137+
- name: "Create Release"
138+
uses: "softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b"
139+
with:
140+
draft: true
141+
tag_name: "${{ steps.get-version.outputs.version }}"
142+
name: "${{ steps.get-version.outputs.version }}"
143+
files: |
144+
${{ github.workspace }}/**/*.tar.gz
145+
${{ github.workspace }}/**/*.zip

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build*/
2+
release/
3+
curl-*/
4+
*.tar.gz
5+
*.zip
6+
.DS_Store

Build-Windows.ps1

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Param($Configuration, $Version, $CurlDirectory)
2+
3+
cmake "$CurlDirectory" -B "build_$Configuration" `
4+
-DCMAKE_BUILD_TYPE="$Configuration" `
5+
-DCURL_USE_OPENSSL=OFF `
6+
-DCURL_USE_SCHANNEL=ON `
7+
-DBUILD_CURL_EXE=OFF `
8+
-DBUILD_SHARED_LIBS=OFF `
9+
-DHTTP_ONLY=ON `
10+
-DCURL_USE_LIBSSH2=OFF `
11+
-DBUILD_TESTING=OFF `
12+
-DPICKY_COMPILER=OFF `
13+
14+
cmake --build "build_$Configuration" --config "$Configuration"
15+
cmake --install "build_$Configuration" --config "$Configuration" --prefix "release/$Configuration"
16+
Compress-Archive "release\$Configuration\*" "release\libcurl-windows-$Version-$Configuration.zip" -Verbose

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# kaito-tokyo-obs-dep-libcurl
1+
# kaito-tokyo-obs-dep-libcurl
2+
3+
## Build instructions for macOS
4+
5+
```
6+
curl -LO https://github.com/curl/curl/archive/refs/tags/curl-8_7_1.tar.gz
7+
tar -xf curl-8_7_1.tar.gz
8+
./build-macos.sh
9+
```
10+
11+
## Build instructions for Windows
12+
13+
```
14+
curl -LO https://github.com/curl/curl/archive/refs/tags/curl-8_7_1.tar.gz
15+
tar -xf curl-8_7_1.tar.gz
16+
./build-macos.sh
17+
```

build-macos.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
CONFIG="${1?}"
6+
VERSION="${2?}"
7+
CURL_DIR="${3?}"
8+
9+
cmake "$CURL_DIR" -B "build_$CONFIG" \
10+
-DCMAKE_BUILD_TYPE="$CONFIG" \
11+
-DCURL_USE_OPENSSL=OFF \
12+
-DCURL_USE_SECTRANSP=ON \
13+
-DBUILD_CURL_EXE=OFF \
14+
-DBUILD_SHARED_LIBS=OFF \
15+
-DHTTP_ONLY=ON \
16+
-DCURL_USE_LIBSSH2=OFF \
17+
-DBUILD_TESTING=OFF \
18+
-DPICKY_COMPILER=OFF
19+
20+
cmake --build "build_$CONFIG"
21+
cmake --install "build_$CONFIG" --prefix "release/$CONFIG"
22+
tar -C "release/$CONFIG" -cvf "release/libcurl-macos-$VERSION-$CONFIG.tar.gz" .

0 commit comments

Comments
 (0)