Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0269277ac8 | ||
|
|
ee0e7d44fd | ||
|
|
28f00d3dc6 | ||
|
|
a30646e3b1 |
32
.github/workflows/README.md
vendored
Normal file
32
.github/workflows/README.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# Building Hero for release
|
||||
|
||||
Generally speaking, our scripts and docs for building hero produce non portable binaries for Linux. While that's fine for development purposes, statically linked binaries are much more convenient for releases and distribution.
|
||||
|
||||
The release workflow here creates a static binary for Linux using an Alpine container. A few notes follow about how that's done.
|
||||
|
||||
## Static builds in vlang
|
||||
|
||||
Since V compiles to C in our case, we are really concerned with how to produce static C builds. The V project provides [some guidance](https://github.com/vlang/v?tab=readme-ov-file#docker-with-alpinemusl) on using an Alpine container and passing `-cflags -static` to the V compiler.
|
||||
|
||||
That's fine for some projects. Hero has a dependency on the `libpq` C library for Postgres functionality, however, and this creates a complication.
|
||||
|
||||
## Static linking libpq
|
||||
|
||||
In order to create a static build of hero on Alpine, we need to install some additional packages:
|
||||
|
||||
* openssl-libs-static
|
||||
* postgresql-dev
|
||||
|
||||
The full `apk` command to prepare the container for building looks like this:
|
||||
|
||||
```bash
|
||||
apk add --no-cache bash git build-base openssl-dev libpq-dev postgresql-dev openssl-libs-static
|
||||
```
|
||||
|
||||
Then we also need to instruct the C compiler to link against the Postgres static shared libraries. Here's the build command:
|
||||
|
||||
```bash
|
||||
v -w -d use_openssl -enable-globals -cc gcc -cflags -static -ldflags "-lpgcommon_shlib -lpgport_shlib" cli/hero.v
|
||||
```
|
||||
|
||||
Note that gcc is also the preferred compiler for static builds.
|
||||
7
.github/workflows/hero_build.yml
vendored
7
.github/workflows/hero_build.yml
vendored
@@ -78,13 +78,6 @@ jobs:
|
||||
v -w -d use_openssl -enable-globals -cc clang cli/hero.v -o cli/hero-${{ matrix.target }}
|
||||
fi
|
||||
|
||||
- name: Upload glibc binary
|
||||
if: runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: hero-${{ matrix.target }}
|
||||
path: cli/hero-${{ matrix.target }}
|
||||
|
||||
- name: Upload musl binary
|
||||
if: runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
@@ -53,7 +53,7 @@ fn do() ! {
|
||||
mut cmd := Command{
|
||||
name: 'hero'
|
||||
description: 'Your HERO toolset.'
|
||||
version: '1.0.36'
|
||||
version: '1.0.38'
|
||||
}
|
||||
|
||||
mut toinstall := false
|
||||
@@ -103,4 +103,4 @@ fn main() {
|
||||
print_backtrace()
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ os.write_file(hero_v_path, lines.join_lines()) or {
|
||||
os.rm('${hero_v_path}.backup') or { eprintln('Warning: Could not remove backup file: ${err}') }
|
||||
|
||||
// Update version in install_hero.sh
|
||||
install_hero_path := '${ourdir}/install_hero.sh'
|
||||
install_hero_path := '${ourdir}/scripts/install_hero.sh'
|
||||
install_hero_content := os.read_file(install_hero_path) or {
|
||||
eprintln('Error reading ${install_hero_path}: ${err}')
|
||||
exit(1)
|
||||
|
||||
@@ -4,7 +4,7 @@ set -e
|
||||
|
||||
os_name="$(uname -s)"
|
||||
arch_name="$(uname -m)"
|
||||
version='1.0.36'
|
||||
version='1.0.38'
|
||||
|
||||
# Detect Linux distribution type
|
||||
linux_type=""
|
||||
@@ -138,4 +138,4 @@ if [ "$file_size" -ge 2 ]; then
|
||||
else
|
||||
echo "Downloaded file is less than 2 MB. Process aborted."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user