Skip to content

Commit

Permalink
feat: maintenance and add anonymized telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
dpeckett committed Sep 4, 2024
1 parent 14f2659 commit 89d008f
Show file tree
Hide file tree
Showing 35 changed files with 4,255 additions and 643 deletions.
4 changes: 3 additions & 1 deletion .earthlyignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/dist/
/dist/
/airgapify
*.tar*
30 changes: 18 additions & 12 deletions .github/workflows/main.yml → .github/workflows/earthly.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test
name: Build, Test, and Release

on:
push:
Expand All @@ -10,50 +10,56 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
DO_NOT_TRACK: '1'

steps:
- uses: earthly/actions-setup@v1
with:
version: v0.7.23
version: v0.8.14

- name: Check Out Repo
uses: actions/checkout@v3

- name: Lint
run: earthly +lint

- name: Build
run: |
earthly +generate
earthly +build
- name: Test
run: earthly +test

release:
needs: build-and-test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
env:
DO_NOT_TRACK: '1'

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: earthly/actions-setup@v1
with:
version: v0.7.23
version: v0.8.14

- name: Check Out Repo
uses: actions/checkout@v3

- name: Build
run: |
earthly +generate
earthly +all
run: earthly +all --VERSION=${{ github.ref_name }}

- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
checksums.txt
LICENSE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Binaries for programs and plugins
/dist/
/airgapify
*.exe
*.exe~
*.dll
Expand Down
76 changes: 61 additions & 15 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
VERSION 0.7
FROM golang:1.21-bookworm
WORKDIR /app
VERSION 0.8
FROM golang:1.22-bookworm
WORKDIR /workspace

all:
ARG VERSION=dev
BUILD +generate
COPY (+build/airgapify --GOARCH=amd64) ./dist/airgapify-linux-amd64
COPY (+build/airgapify --GOARCH=arm64) ./dist/airgapify-linux-arm64
COPY (+build/airgapify --GOARCH=riscv64) ./dist/airgapify-linux-riscv64
COPY (+build/airgapify --GOOS=darwin --GOARCH=amd64) ./dist/airgapify-darwin-amd64
COPY (+build/airgapify --GOOS=darwin --GOARCH=arm64) ./dist/airgapify-darwin-arm64
RUN cd dist && find . -type f -exec sha256sum {} \; >> ../checksums.txt
SAVE ARTIFACT ./dist/airgapify-linux-amd64 AS LOCAL dist/airgapify-linux-amd64
SAVE ARTIFACT ./dist/airgapify-linux-arm64 AS LOCAL dist/airgapify-linux-arm64
SAVE ARTIFACT ./dist/airgapify-darwin-amd64 AS LOCAL dist/airgapify-darwin-amd64
SAVE ARTIFACT ./dist/airgapify-darwin-arm64 AS LOCAL dist/airgapify-darwin-arm64
SAVE ARTIFACT ./checksums.txt AS LOCAL dist/checksums.txt
COPY (+build/airgapify --GOOS=windows --GOARCH=amd64) ./dist/airgapify-windows-amd64.exe
COPY (+package/*.deb --GOARCH=amd64) ./dist/
COPY (+package/*.deb --GOARCH=arm64) ./dist/
COPY (+package/*.deb --GOARCH=riscv64) ./dist/
RUN cd dist && find . -type f | sort | xargs sha256sum >> ../sha256sums.txt
SAVE ARTIFACT ./dist/* AS LOCAL dist/
SAVE ARTIFACT ./sha256sums.txt AS LOCAL dist/sha256sums.txt

build:
ARG GOOS=linux
ARG GOARCH=amd64
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build --ldflags '-s' -o airgapify cmd/main.go
ARG VERSION=dev
RUN CGO_ENABLED=0 go build --ldflags "-s -X 'github.com/dpeckett/airgapify/internal/constants.Version=${VERSION}'" -o airgapify main.go
SAVE ARTIFACT ./airgapify AS LOCAL dist/airgapify-${GOOS}-${GOARCH}

generate:
ARG CONTROLLER_TOOLS_VERSION=v0.12.0
ARG CONTROLLER_TOOLS_VERSION=v0.16.2
RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_TOOLS_VERSION}
COPY . ./
RUN controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
Expand All @@ -34,16 +39,57 @@ generate:

tidy:
LOCALLY
ENV GOTOOLCHAIN=go1.22.1
RUN go mod tidy
RUN go fmt ./...

lint:
FROM golangci/golangci-lint:v1.55.2
WORKDIR /app
FROM golangci/golangci-lint:v1.59.1
WORKDIR /workspace
COPY . ./
RUN golangci-lint run --timeout 5m ./...

test:
COPY . ./
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go test -coverprofile=coverage.out -v ./...
SAVE ARTIFACT ./coverage.out AS LOCAL coverage.out
SAVE ARTIFACT ./coverage.out AS LOCAL coverage.out

package:
FROM debian:bookworm
# Use bookworm-backports for newer golang versions
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list
RUN apt update
# Tooling
RUN apt install -y git curl devscripts dpkg-dev debhelper-compat git-buildpackage libfaketime dh-sequence-golang \
golang-any=2:1.22~3~bpo12+1 golang-go=2:1.22~3~bpo12+1 golang-src=2:1.22~3~bpo12+1 \
gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu
RUN curl -fsL -o /etc/apt/keyrings/apt-pecke-tt-keyring.asc https://apt.pecke.tt/signing_key.asc \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/apt-pecke-tt-keyring.asc] http://apt.pecke.tt $(. /etc/os-release && echo $VERSION_CODENAME) stable" > /etc/apt/sources.list.d/apt-pecke-tt.list \
&& apt update
# Build Dependencies
RUN apt install -y \
golang-github-dpeckett-archivefs-dev \
golang-github-dpeckett-telemetry-dev \
golang-github-dpeckett-uncompr-dev \
golang-github-google-go-containerregistry-dev \
golang-github-pierrec-lz4-dev=4.1.18-1~bpo12+1 \
golang-github-stretchr-testify-dev \
golang-github-urfave-cli-v2-dev \
golang-k8s-apimachinery-dev
RUN mkdir -p /workspace/airgapify
WORKDIR /workspace/airgapify
COPY . .
RUN if [ -n "$(git status --porcelain)" ]; then echo "Please commit your changes."; exit 1; fi
RUN if [ -z "$(git describe --tags --exact-match 2>/dev/null)" ]; then echo "Current commit is not tagged."; exit 1; fi
COPY debian/scripts/generate-changelog.sh /usr/local/bin/generate-changelog.sh
RUN chmod +x /usr/local/bin/generate-changelog.sh
ENV DEBEMAIL="[email protected]"
ENV DEBFULLNAME="Damian Peckett"
RUN /usr/local/bin/generate-changelog.sh
RUN VERSION=$(git describe --tags --abbrev=0 | tr -d 'v') \
&& tar -czf ../airgapify_${VERSION}.orig.tar.gz --exclude-vcs .
ARG GOARCH
RUN dpkg-buildpackage -d -us -uc --host-arch=${GOARCH}
SAVE ARTIFACT /workspace/*.deb AS LOCAL dist/
Loading

0 comments on commit 89d008f

Please sign in to comment.