Skip to content

Add option to disable TUI entirely (silent mode) (#112) #53

Add option to disable TUI entirely (silent mode) (#112)

Add option to disable TUI entirely (silent mode) (#112) #53

Workflow file for this run

name: Release
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
force:
description: Force release build even when shared filter says no relevant changes
required: false
default: false
type: boolean
push:
tags:
- 'v*'
permissions:
contents: write
pages: write
id-token: write
env:
NFPM_VERSION: v2.45.0
jobs:
changes:
runs-on: ubuntu-latest
outputs:
run_release: ${{ steps.filter.outputs.ci }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- id: filter
uses: ./.github/actions/common-ci-filter
tag-guard:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Verify tag commit is on main
run: |
git fetch origin main:refs/remotes/origin/main
if git merge-base --is-ancestor "$GITHUB_SHA" "origin/main"; then
echo "Tag commit is on main."
else
echo "Tag commit is not on main. Refusing to release."
exit 1
fi
build:
needs: changes
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.force == 'true' || needs.changes.outputs.run_release == 'true'
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
name: etr-linux-amd64
container: ""
- os: ubuntu-latest
goos: linux
goarch: amd64
name: etr-linux-amd64-glibc-2.31
container: debian:bullseye-slim
- os: ubuntu-22.04-arm
goos: linux
goarch: arm64
name: etr-linux-arm64
container: ""
- os: ubuntu-22.04-arm
goos: linux
goarch: arm64
name: etr-linux-arm64-glibc-2.31
container: debian:bullseye-slim
- os: macos-15-intel # Intel - macOS 15 will be the last Intel runner
goos: darwin
goarch: amd64
name: etr-darwin-amd64
container: ""
- os: macos-latest # Apple Silicon
goos: darwin
goarch: arm64
name: etr-darwin-arm64
container: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Install libpcap (Linux)
if: runner.os == 'Linux' && matrix.container == ''
run: |
sudo apt-get update
sudo apt-get install -y libpcap-dev
- name: Build binary (Linux, container)
if: runner.os == 'Linux' && matrix.container != ''
run: |
VERSION=${GITHUB_REF#refs/tags/v}
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
docker run --rm \
-v "$GITHUB_WORKSPACE":/work \
-w /work \
-e VERSION="$VERSION" \
-e COMMIT="$COMMIT" \
-e DATE="$DATE" \
${{ matrix.container }} \
bash -lc '
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl git build-essential pkg-config libpcap-dev &&
GO_MINOR=$(awk "/^go /{print \$2}" go.mod) &&
GO_VERSION=$(curl -fsSL "https://go.dev/dl/?mode=json" | \
grep -o "\"version\": \"go${GO_MINOR}\\.[0-9][0-9]*\"" | \
head -n 1 | sed -E "s/.*\"go([0-9.]+)\"/\1/") &&
ARCH=$(uname -m) &&
case "$ARCH" in
x86_64) GOARCH=amd64 ;;
aarch64|arm64) GOARCH=arm64 ;;
*) echo "Unsupported arch: $ARCH"; exit 1 ;;
esac &&
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${GOARCH}.tar.gz" -o /tmp/go.tgz &&
tar -C /usr/local -xzf /tmp/go.tgz &&
export PATH=/usr/local/go/bin:$PATH &&
LDFLAGS="-X github.com/tkjaer/etr/internal/version.Version=${VERSION} \
-X github.com/tkjaer/etr/internal/version.GitCommit=${COMMIT} \
-X github.com/tkjaer/etr/internal/version.BuildDate=${DATE}" &&
GOOS=linux GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 \
go build -buildvcs=false -ldflags="$LDFLAGS" -o ${{ matrix.name }} ./cmd/etr
'
- name: Build binary
if: matrix.container == ''
run: |
VERSION=${GITHUB_REF#refs/tags/v}
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS="-X github.com/tkjaer/etr/internal/version.Version=${VERSION} \
-X github.com/tkjaer/etr/internal/version.GitCommit=${COMMIT} \
-X github.com/tkjaer/etr/internal/version.BuildDate=${DATE}"
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -buildvcs=false -ldflags="${LDFLAGS}" -o ${{ matrix.name }} ./cmd/etr
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
linux-packages:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goarch: amd64
artifact_name: etr-linux-amd64-glibc-2.31
rpm_arch: x86_64
- goarch: arm64
artifact_name: etr-linux-arm64-glibc-2.31
rpm_arch: aarch64
steps:
- uses: actions/checkout@v5
- name: Download Linux binary artifact
uses: actions/download-artifact@v8
with:
name: ${{ matrix.artifact_name }}
path: dist
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${{ env.NFPM_VERSION }}
- name: Build deb and rpm
env:
VERSION: ${{ github.ref_name }}
run: |
VERSION="${VERSION#v}"
install -m 0755 "dist/${{ matrix.artifact_name }}" dist/etr
ARCH="${{ matrix.goarch }}" VERSION="$VERSION" nfpm package --packager deb --config ./nfpm.yaml --target "dist/etr_${VERSION}_${{ matrix.goarch }}.deb"
ARCH="${{ matrix.rpm_arch }}" VERSION="$VERSION" nfpm package --packager rpm --config ./nfpm.yaml --target "dist/etr-${VERSION}-1.${{ matrix.rpm_arch }}.rpm"
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: etr-packages-${{ matrix.goarch }}
path: |
dist/*.deb
dist/*.rpm
release:
needs: [build, linux-packages, tag-guard]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
find artifacts -type f -maxdepth 3 -exec cp {} release/ \;
cd release
sha256sum * > checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true
draft: false
prerelease: false
apt-repo:
if: startsWith(github.ref, 'refs/tags/v')
needs: [release]
uses: ./.github/workflows/reusable-apt-pages.yml
with:
package_name: etr
suite: stable
component: main
architectures: amd64 arm64
key_expiry_warn_days: 90
key_expiry_fail_days: 14
secrets:
APT_GPG_PRIVATE_KEY: ${{ secrets.APT_GPG_PRIVATE_KEY }}
APT_GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }}