Files
flores/.gitea/workflows/test-package.yml
T
Sianao e6ca1b0528
Test and package / Test and package Linux binary (push) Successful in 16m15s
ci: add Gitea test and package workflow
2026-08-22 00:10:57 +08:00

85 lines
2.1 KiB
YAML

name: Test and package
on:
push:
pull_request:
workflow_dispatch:
jobs:
test-package:
name: Test and package Linux binary
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Install native build dependencies
shell: bash
run: |
set -euo pipefail
if [ "$(id -u)" -eq 0 ]; then
apt=(apt-get)
elif command -v sudo >/dev/null 2>&1; then
apt=(sudo apt-get)
else
echo "The runner user needs root access or sudo to install build dependencies." >&2
exit 1
fi
"${apt[@]}" update
"${apt[@]}" install --yes --no-install-recommends \
gcc \
libc6-dev \
libassuan-dev \
libbtrfs-dev \
libdevmapper-dev \
libglib2.0-dev \
libgpg-error-dev \
libgpgme-dev \
libprotobuf-c-dev \
libprotobuf-dev \
libseccomp-dev \
libselinux1-dev \
libsystemd-dev \
pkg-config
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24.x"
cache: true
- name: Verify dependencies
run: go mod verify
- name: Run tests
run: go test ./...
- name: Build package
shell: bash
run: |
set -euo pipefail
arch="$(go env GOARCH)"
package="floares-linux-${arch}"
mkdir -p "dist/${package}"
go build -trimpath -ldflags="-s -w" -o "dist/${package}/floares" .
cp LICENSE README.md "dist/${package}/"
tar -C dist -czf "dist/${package}.tar.gz" "${package}"
sha256sum "dist/${package}.tar.gz" > "dist/${package}.tar.gz.sha256"
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: floares-linux
path: |
dist/*.tar.gz
dist/*.sha256
if-no-files-found: error
retention-days: 14