82 lines
2.8 KiB
YAML
82 lines
2.8 KiB
YAML
stages:
|
|
- build
|
|
|
|
build_sshpiper:
|
|
stage: build
|
|
tags:
|
|
- build
|
|
only:
|
|
- main
|
|
before_script:
|
|
# Install Go 1.23+ (required for sshpiper)
|
|
- |
|
|
GO_VERSION="1.23.4"
|
|
GO_INSTALL_DIR="$HOME/go-${GO_VERSION}"
|
|
GO_TARBALL="$HOME/go${GO_VERSION}.linux-amd64.tar.gz"
|
|
if [ ! -d "$GO_INSTALL_DIR" ]; then
|
|
echo "Installing Go ${GO_VERSION} to $GO_INSTALL_DIR..."
|
|
if [ ! -f "$GO_TARBALL" ]; then
|
|
echo "Downloading Go ${GO_VERSION}..."
|
|
wget -q https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O "$GO_TARBALL"
|
|
else
|
|
echo "Using cached Go tarball"
|
|
fi
|
|
cd $HOME
|
|
tar -xzf "$GO_TARBALL"
|
|
mv go go-${GO_VERSION}
|
|
echo "Go ${GO_VERSION} installed successfully"
|
|
else
|
|
echo "Go ${GO_VERSION} already installed at $GO_INSTALL_DIR"
|
|
fi
|
|
- export GOROOT=$HOME/go-${GO_VERSION}
|
|
- export GOPATH=$HOME/go
|
|
- export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
|
|
- $GOROOT/bin/go version
|
|
script:
|
|
- echo "Building sshpiper with fingerprint passthrough..."
|
|
- export GO_VERSION="1.23.4"
|
|
- export GOROOT=$HOME/go-${GO_VERSION}
|
|
- export GOPATH=$HOME/go
|
|
- export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
|
|
- cd $CI_PROJECT_DIR
|
|
# Initialize submodules (crypto fork)
|
|
- git submodule update --init --recursive
|
|
# Build sshpiperd
|
|
- $GOROOT/bin/go build -tags full -o sshpiperd ./cmd/sshpiperd
|
|
- |
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to build sshpiperd. Aborting."
|
|
exit 1
|
|
fi
|
|
- echo "sshpiperd built successfully."
|
|
# Build yaml plugin (separate binary, required for fingerprint passthrough)
|
|
- $GOROOT/bin/go build -tags full -o yaml ./plugin/yaml
|
|
- |
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to build yaml plugin. Aborting."
|
|
exit 1
|
|
fi
|
|
- echo "yaml plugin built successfully."
|
|
# Build api plugin (for multi-pool routing via API lookup)
|
|
- $GOROOT/bin/go build -tags full -o api ./plugin/api
|
|
- |
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to build api plugin. Aborting."
|
|
exit 1
|
|
fi
|
|
- echo "api plugin built successfully."
|
|
- ./sshpiperd --help 2>&1 | head -20 || true
|
|
# Push both binaries to salt master via minionfs for distribution to minions
|
|
- echo "Pushing sshpiper binaries to salt master via minionfs..."
|
|
- mkdir -p $HOME/sshpiper-dist
|
|
- tar -czvf $HOME/sshpiper-dist/sshpiper.tar.gz -C $CI_PROJECT_DIR sshpiperd yaml api
|
|
- echo "$(git rev-parse --short HEAD)" > $HOME/sshpiper-dist/commit-hash.txt
|
|
- ls -la $HOME/sshpiper-dist/
|
|
- sudo /opt/salt-call-put-artifacts-onto-salt-master.sh $HOME/sshpiper-dist
|
|
- echo "sshpiper binary pushed to salt master via minionfs"
|
|
artifacts:
|
|
paths:
|
|
- sshpiperd
|
|
- yaml
|
|
- api
|
|
expire_in: 1 week
|