Compare commits
No commits in common. "80b1d49e746152bb9bafed6bc3f0ac65b2592b91" and "a27930de8571f910a38022ac8d900eb463e27a02" have entirely different histories.
80b1d49e74
...
a27930de85
4 changed files with 3 additions and 273 deletions
|
@ -1,255 +0,0 @@
|
||||||
name: Build for Releases
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ensure-release-exists:
|
|
||||||
runs-on: any_archLinux
|
|
||||||
steps:
|
|
||||||
- name: Check release and create if it doesn't exist
|
|
||||||
run: |
|
|
||||||
THE_ACTION_WORKING_DIRECTORY="$(pwd)"
|
|
||||||
curl -X GET "https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/tags/$GITHUB_REF_NAME" \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_${GITHUB_REF_NAME}_check.json" \
|
|
||||||
-w '%{http_code}' 2>/dev/null > release_${GITHUB_REF_NAME}_check_code
|
|
||||||
if [[ "404" == "$(cat release_${GITHUB_REF_NAME}_check_code)" ]]; then
|
|
||||||
curl --fail-with-body -X POST \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"body\": \" SHA256SUMS\",
|
|
||||||
\"name\": \"c_simple_http version ${GITHUB_REF_NAME}\",
|
|
||||||
\"tag_name\": \"${GITHUB_REF_NAME}\" }" 2>/dev/null > "${THE_ACTION_WORKING_DIRECTORY}/release_${GITHUB_REF_NAME}_create.json"
|
|
||||||
fi
|
|
||||||
|
|
||||||
push-build-x86_64:
|
|
||||||
needs: ensure-release-exists
|
|
||||||
concurrency:
|
|
||||||
group: push-build-group
|
|
||||||
runs-on: x86_64_archLinux
|
|
||||||
steps:
|
|
||||||
- name: Check release assets and build for x86_64
|
|
||||||
run: |
|
|
||||||
THE_ACTION_WORKING_DIRECTORY="$(pwd)"
|
|
||||||
BUILD_ASSET_NAME="c_simple_http_x86_64_${GITHUB_REF_NAME}.zst"
|
|
||||||
curl -X GET \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/tags/${GITHUB_REF_NAME}" \
|
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" 2>/dev/null
|
|
||||||
BUILD_ASSET_EXISTS=0
|
|
||||||
for asset in $(jq '.assets.[].name' < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" | tr -d '"'); do
|
|
||||||
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
|
||||||
BUILD_ASSET_EXISTS=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if ! (( BUILD_ASSET_EXISTS )); then
|
|
||||||
if ! [[ -d "c_simple_http_clone" ]]; then
|
|
||||||
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/c_simple_http.git c_simple_http_clone
|
|
||||||
fi
|
|
||||||
pushd c_simple_http_clone >&/dev/null
|
|
||||||
git clean -xfd && git restore . && git checkout "${GITHUB_REF_NAME}"
|
|
||||||
git submodule update --init --recursive --depth=1 --no-single-branch
|
|
||||||
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
|
|
||||||
make -C buildRelease c_simple_http
|
|
||||||
strip --strip-unneeded buildRelease/c_simple_http
|
|
||||||
zstd --ultra -20 buildRelease/c_simple_http -o "${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME}"
|
|
||||||
curl --fail-with-body -X GET \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" 2>/dev/null
|
|
||||||
curl --fail-with-body -X PATCH \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"body\": \"$(jq .body < "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" | sed -e 's/^"//' -e 's/"$//')
|
|
||||||
$(find "${THE_ACTION_WORKING_DIRECTORY}" -maxdepth 1 -name "*${BUILD_ASSET_NAME}" -execdir sha256sum '{}' ';' | sed -e 's|\./c_simple|c_simple|')\"
|
|
||||||
}" >&/dev/null
|
|
||||||
curl --fail-with-body -X POST \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")/assets" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-F "attachment=@${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME};type=application/zstd" > "${THE_ACTION_WORKING_DIRECTORY}/attach_${GITHUB_REF_NAME}.json" 2>/dev/null
|
|
||||||
popd >&/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
push-build-aarch64:
|
|
||||||
if: ${{ always() }}
|
|
||||||
needs: push-build-x86_64
|
|
||||||
concurrency:
|
|
||||||
group: push-build-group
|
|
||||||
runs-on: aarch64_archLinux
|
|
||||||
steps:
|
|
||||||
- name: Check release assets and build for aarch64
|
|
||||||
run: |
|
|
||||||
THE_ACTION_WORKING_DIRECTORY="$(pwd)"
|
|
||||||
BUILD_ASSET_NAME="c_simple_http_aarch64_${GITHUB_REF_NAME}.zst"
|
|
||||||
curl -X GET \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/tags/${GITHUB_REF_NAME}" \
|
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" 2>/dev/null
|
|
||||||
BUILD_ASSET_EXISTS=0
|
|
||||||
for asset in $(jq '.assets.[].name' < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json" | tr -d '"'); do
|
|
||||||
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
|
||||||
BUILD_ASSET_EXISTS=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if ! (( BUILD_ASSET_EXISTS )); then
|
|
||||||
if ! [[ -d "c_simple_http_clone" ]]; then
|
|
||||||
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/c_simple_http.git c_simple_http_clone
|
|
||||||
fi
|
|
||||||
pushd c_simple_http_clone >&/dev/null
|
|
||||||
git clean -xfd && git restore . && git checkout "${GITHUB_REF_NAME}"
|
|
||||||
git submodule update --init --recursive --depth=1 --no-single-branch
|
|
||||||
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
|
|
||||||
make -C buildRelease c_simple_http
|
|
||||||
strip --strip-unneeded buildRelease/c_simple_http
|
|
||||||
zstd --ultra -20 buildRelease/c_simple_http -o "${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME}"
|
|
||||||
curl --fail-with-body -X GET \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
|
||||||
-H 'accept: application/json' -o "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" 2>/dev/null
|
|
||||||
curl --fail-with-body -X PATCH \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"body\": \"$(jq .body < "${THE_ACTION_WORKING_DIRECTORY}/current_release_info.json" | sed -e 's/^"//' -e 's/"$//')
|
|
||||||
$(find "${THE_ACTION_WORKING_DIRECTORY}" -maxdepth 1 -name "*${BUILD_ASSET_NAME}" -execdir sha256sum '{}' ';' | sed -e 's|\./c_simple|c_simple|')\"
|
|
||||||
}" >&/dev/null
|
|
||||||
curl --fail-with-body -X POST \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < "${THE_ACTION_WORKING_DIRECTORY}/release_info.json")/assets" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-F "attachment=@${THE_ACTION_WORKING_DIRECTORY}/${BUILD_ASSET_NAME};type=application/zstd" > "${THE_ACTION_WORKING_DIRECTORY}/attach_${GITHUB_REF_NAME}.json" 2>/dev/null
|
|
||||||
popd >&/dev/null
|
|
||||||
fi
|
|
||||||
push-build-x86_64_debian:
|
|
||||||
if: ${{ always() }}
|
|
||||||
needs: push-build-aarch64
|
|
||||||
concurrency:
|
|
||||||
group: push-build-group
|
|
||||||
runs-on: docker_debian_bookworm
|
|
||||||
env:
|
|
||||||
BUILD_ASSET_NAME: "c_simple_http_x86_64_debian_${{ github.ref_name }}.zst"
|
|
||||||
steps:
|
|
||||||
- name: Update and upgrade with apt
|
|
||||||
run: apt-get --yes update && apt-get --yes upgrade
|
|
||||||
- name: Get necessary packages
|
|
||||||
run: apt-get --yes install gcc g++ jq curl cmake make zstd sed git
|
|
||||||
- name: Get release info
|
|
||||||
run: |
|
|
||||||
curl -X GET \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/tags/${GITHUB_REF_NAME}" \
|
|
||||||
-H 'accept: application/json' -o release_info.json
|
|
||||||
- name: Check if asset exists
|
|
||||||
run: |
|
|
||||||
for asset in $(jq '.assets[].name' < release_info.json | tr -d '"'); do
|
|
||||||
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
|
||||||
touch asset_exists
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
- name: Build and publish if asset does not exist
|
|
||||||
run: |
|
|
||||||
if ! [[ -e ./asset_exists ]]; then
|
|
||||||
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/c_simple_http.git c_simple_http_clone
|
|
||||||
pushd c_simple_http_clone >&/dev/null
|
|
||||||
|
|
||||||
git checkout "${GITHUB_REF_NAME}"
|
|
||||||
git submodule update --init --recursive --depth=1 --no-single-branch
|
|
||||||
|
|
||||||
# Patch CMakeLists.txt as some flags aren't yet supported by Debian's GCC.
|
|
||||||
sed -i -e 's/-fstrict-flex-arrays=3//g' CMakeLists.txt
|
|
||||||
|
|
||||||
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
|
|
||||||
make -C buildRelease c_simple_http
|
|
||||||
|
|
||||||
popd >&/dev/null
|
|
||||||
zstd --ultra -20 c_simple_http_clone/buildRelease/c_simple_http -o "${BUILD_ASSET_NAME}"
|
|
||||||
|
|
||||||
curl --fail-with-body -X PATCH \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < release_info.json)" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"body\": \"$(jq .body < release_info.json | sed -e 's/^"//' -e 's/"$//')
|
|
||||||
$(sha256sum "${BUILD_ASSET_NAME}")\"
|
|
||||||
}" >&/dev/null
|
|
||||||
|
|
||||||
curl --fail-with-body -X POST \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < release_info.json)/assets" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-F "attachment=@${BUILD_ASSET_NAME};type=application/zstd" > attach.json 2>/dev/null
|
|
||||||
fi
|
|
||||||
push-build-aarch64_debian:
|
|
||||||
if: ${{ always() }}
|
|
||||||
needs: push-build-x86_64_debian
|
|
||||||
concurrency:
|
|
||||||
group: push-build-group
|
|
||||||
runs-on: aarch64_docker_debian_bookworm
|
|
||||||
env:
|
|
||||||
BUILD_ASSET_NAME: "c_simple_http_aarch64_debian_${{ github.ref_name }}.zst"
|
|
||||||
steps:
|
|
||||||
- name: Update and upgrade with apt
|
|
||||||
run: apt-get --yes update && apt-get --yes upgrade
|
|
||||||
- name: Get necessary packages
|
|
||||||
run: apt-get --yes install gcc g++ jq curl cmake make zstd sed git
|
|
||||||
- name: Get release info
|
|
||||||
run: |
|
|
||||||
curl -X GET \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/tags/${GITHUB_REF_NAME}" \
|
|
||||||
-H 'accept: application/json' -o release_info.json
|
|
||||||
- name: Check if asset exists
|
|
||||||
run: |
|
|
||||||
for asset in $(jq '.assets[].name' < release_info.json | tr -d '"'); do
|
|
||||||
if [[ "$asset" == "$BUILD_ASSET_NAME" ]]; then
|
|
||||||
touch asset_exists
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
- name: Build and publish if asset does not exist
|
|
||||||
run: |
|
|
||||||
if ! [[ -e ./asset_exists ]]; then
|
|
||||||
git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/c_simple_http.git c_simple_http_clone
|
|
||||||
pushd c_simple_http_clone >&/dev/null
|
|
||||||
|
|
||||||
git checkout "${GITHUB_REF_NAME}"
|
|
||||||
git submodule update --init --recursive --depth=1 --no-single-branch
|
|
||||||
|
|
||||||
# Patch CMakeLists.txt as some flags aren't yet supported by Debian's GCC.
|
|
||||||
sed -i -e 's/-fstrict-flex-arrays=3//g' CMakeLists.txt
|
|
||||||
|
|
||||||
cmake -S . -B buildRelease -DCMAKE_BUILD_TYPE=Release
|
|
||||||
make -C buildRelease c_simple_http
|
|
||||||
|
|
||||||
popd >&/dev/null
|
|
||||||
zstd --ultra -20 c_simple_http_clone/buildRelease/c_simple_http -o "${BUILD_ASSET_NAME}"
|
|
||||||
|
|
||||||
curl --fail-with-body -X PATCH \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < release_info.json)" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"body\": \"$(jq .body < release_info.json | sed -e 's/^"//' -e 's/"$//')
|
|
||||||
$(sha256sum "${BUILD_ASSET_NAME}")\"
|
|
||||||
}" >&/dev/null
|
|
||||||
|
|
||||||
curl --fail-with-body -X POST \
|
|
||||||
"https://git.seodisparate.com/api/v1/repos/stephenseo/c_simple_http/releases/$(jq .id < release_info.json)/assets" \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-F "attachment=@${BUILD_ASSET_NAME};type=application/zstd" > attach.json 2>/dev/null
|
|
||||||
fi
|
|
14
Changelog.md
14
Changelog.md
|
@ -1,14 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
## Latest Changes
|
|
||||||
|
|
||||||
## Version 1.0
|
|
||||||
|
|
||||||
First release.
|
|
||||||
|
|
||||||
Features:
|
|
||||||
|
|
||||||
- Serve templated html files via a config.
|
|
||||||
- Reload configuration on SIGUSR1 or by listening (enabled by cmd parameter).
|
|
||||||
- Cache served html (enabled by cmd parameter).
|
|
||||||
- Serve static files from "static-dir" (enabled by cmd parameter).
|
|
|
@ -16,10 +16,6 @@ A simple HTTP/1.1 server written in C.
|
||||||
--cache-entry-lifetime-seconds=<SECONDS>
|
--cache-entry-lifetime-seconds=<SECONDS>
|
||||||
--enable-static-dir=<DIR>
|
--enable-static-dir=<DIR>
|
||||||
|
|
||||||
## Changelog
|
|
||||||
|
|
||||||
See the [Changelog.](https://git.seodisparate.com/stephenseo/c_simple_http/src/branch/main/Changelog.md)
|
|
||||||
|
|
||||||
## Before Compiling
|
## Before Compiling
|
||||||
|
|
||||||
Make sure that the git submodule(s) are loaded:
|
Make sure that the git submodule(s) are loaded:
|
||||||
|
|
|
@ -232,6 +232,8 @@ int c_simple_http_helper_mkdir_tree(const char *path) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (errno == ENOENT) {
|
} else if (errno == ENOENT) {
|
||||||
// Directory doesn't exist, create dir tree.
|
// Directory doesn't exist, create dir tree.
|
||||||
|
closedir(dir_ptr);
|
||||||
|
|
||||||
size_t buf_size = strlen(path) + 1;
|
size_t buf_size = strlen(path) + 1;
|
||||||
char *buf = malloc(buf_size);
|
char *buf = malloc(buf_size);
|
||||||
memcpy(buf, path, buf_size - 1);
|
memcpy(buf, path, buf_size - 1);
|
||||||
|
@ -254,6 +256,7 @@ int c_simple_http_helper_mkdir_tree(const char *path) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// Other directory error.
|
// Other directory error.
|
||||||
|
closedir(dir_ptr);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue