Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/build.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#

name: release
name: Build & Release
on:
pull_request:
push:
branches:
- main
push:
pull_request:
branches:
- main
tags:
Expand All @@ -25,8 +13,55 @@ permissions:
contents: write

jobs:
push_to_registry:
name: Push Docker image to GHCR
native:
strategy:
matrix:
go: [ '1.22', '1.23' ]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Checkout code
uses: actions/checkout@v2
- name: Build project
run: make build
- name: Execute CLI help
run: ./cobbler --help
- name: Upload binary Artifact
uses: actions/upload-artifact@v4
with:
name: cobbler-cli-binary-${{ matrix.go }}-${{ matrix.os }}
path: ./cobbler
rpm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build RPM
run: make build-rpm-docker
- name: Upload RPM Artifact
uses: actions/upload-artifact@v4
with:
name: cobbler-cli-native-rpm
path: ./rpms/**/*.rpm
deb:
# This will fail until Debian 13 will arrive with a newer golang version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build DEB
continue-on-error: true
run: make build-deb-docker
- name: Upload DEB Artifact
uses: actions/upload-artifact@v4
with:
name: cobbler-cli-native-deb
path: ./debs/**/*.deb
docker:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -58,7 +93,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./packaging/docker/Dockerfile
file: ./packaging/docker/production/Dockerfile
push: ${{ env.PUSH_IMAGE }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand All @@ -71,6 +106,11 @@ jobs:
push-to-registry: ${{ env.PUSH_IMAGE }}
goreleaser:
runs-on: ubuntu-latest
needs:
- native
- docker
- deb
- rpm
steps:
- name: Checkout
# https://github.com/actions/checkout
Expand All @@ -80,6 +120,12 @@ jobs:
- name: Set up Go
# https://github.com/actions/setup-go
uses: actions/setup-go@v5
- name: Download all artifacts
# https://github.com/actions/download-artifact
id: download-artifact
uses: actions/download-artifact@v4
with:
pattern: "cobbler-cli-native-*"
- name: Import GPG key
# https://github.com/crazy-max/ghaction-import-gpg
id: import_gpg
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ testing/cobbler_source/
extracted_iso_image/
*.iso
coverage.out

# Packaging
/vendor/
/rpms/

9 changes: 7 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ builds:
- darwin

archives:
- format: tar.gz
- formats: [ 'tar.gz' ]
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
Expand All @@ -34,7 +34,12 @@ archives:
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
formats: [ 'zip' ]
files:
- 'LICENSE*'
- 'README*'
- '**/*.rpm'
- '**/*.deb'

changelog:
sort: asc
Expand Down
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ BINARY_NAME=cobbler
EXECUTOR?=docker
COBBLER_SERVER_URL=http://localhost:8081/cobbler_api
TEST?=$$(go list ./... |grep -v 'vendor')
VERSION=0.0.1

build:
@echo "building package"
Expand All @@ -11,7 +12,32 @@ build:

build-docker:
@echo "building docker"
${EXECUTOR} build -t cobbler/cli:latest -f packaging/docker/Dockerfile .
${EXECUTOR} build -t cobbler/cli:latest -f packaging/docker/production/Dockerfile .

build-rpm-docker:
@docker build -t localhost/cobbler-cli-pkg:opensuse-tumblewed -f packaging/docker/openSUSE_Tumbleweed/Dockerfile .
@docker run --rm -v $(CURDIR)/rpms/openSUSE_Tumbleweed:/root/rpmbuild/RPMS -v $(CURDIR):/workspace localhost/cobbler-cli-pkg:opensuse-tumblewed

build-deb-docker:
@docker build -t localhost/cobbler-cli-pkg:debian-12 -f packaging/docker/Debian_12/Dockerfile .
@docker run --rm -v $(CURDIR)/debs/Debian_12:/usr/src/cobbler-cli/deb-build -v $(CURDIR):/workspace localhost/cobbler-cli-pkg:debian-12

build-rpm:
@cp packaging/rpm/cobbler-cli.spec /root/rpmbuild/SPECS/cobbler-cli.spec
@cd ..; tar --exclude dist --exclude ".idea" --exclude ubuntu-20.04.1-legacy-server-amd64.iso --exclude extracted_iso_image --transform="s/workspace/cobbler-cli-${VERSION}/" -zcvf "cobbler-cli-${VERSION}.tar.gz" /workspace
@mv ../cobbler-cli-${VERSION}.tar.gz /root/rpmbuild/SOURCES
@go mod vendor; tar -zcvf "vendor.tar.gz" vendor; mv vendor.tar.gz /root/rpmbuild/SOURCES
@rpmbuild --define "_topdir /root/rpmbuild" \
--bb /root/rpmbuild/SPECS/cobbler-cli.spec

build-deb:
@mkdir debian; cp -r packaging/deb/* debian/
@cd debian; rename "s/debian\.//" *
@go mod vendor; tar -zcvf "vendor.tar.gz" vendor; mv vendor.tar.gz debian/; rm -r vendor
@cd debian; tar -xvzf vendor.tar.gz
@debuild -us -uc
@rm -r debian
@cp ../cobbler-cli_* /usr/src/cobbler-cli/deb-build

clean:
go clean
Expand Down Expand Up @@ -43,3 +69,5 @@ shell_completions:
./${BINARY_NAME} completion fish > config/completions/fish/cobbler
./${BINARY_NAME} completion powershell > config/completions/powershell/cobbler
./${BINARY_NAME} completion zsh > config/completions/zsh/cobbler

.PHONY: build build-docker build-rpm-docker build-rpm clean cleandoc doc run test shell_completions
8 changes: 4 additions & 4 deletions packaging/deb/debian.rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export PATH := /usr/lib/go/bin:$(PATH)
export CGO_ENABLED = 0

%:
dh $@ --with=bash-completion
dh $@ --with=bash-completion

override_dh_auto_build:
@mv debian/vendor .
dh_auto_build
@mv debian/vendor .
dh_auto_build

override_dh_auto_test:
@echo "Integrations-Tests disabled during build"
@echo "Integrations-Tests disabled during build"
27 changes: 27 additions & 0 deletions packaging/docker/Debian_12/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# vim: ft=dockerfile
FROM docker.io/library/debian:12

ENV DEBIAN_FRONTEND=noninteractive

# Create work directory
WORKDIR /workspace
VOLUME /workspace

# hadolint ignore=DL3008
RUN apt-get update -qq && \
apt-get install --no-install-recommends -qqy \
build-essential \
debhelper \
devscripts \
dh-python \
rename \
git \
bash-completion \
golang-go && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Make directory for debs
RUN mkdir -p /usr/src/cobbler-cli/deb-build
VOLUME /usr/src/cobbler-cli/deb-build

ENTRYPOINT ["make", "build-deb"]
23 changes: 23 additions & 0 deletions packaging/docker/openSUSE_Tumbleweed/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# vim: ft=dockerfile
# hadolint ignore=DL3006
FROM opensuse/tumbleweed

# Create work directory
WORKDIR /workspace
VOLUME /workspace

# Install required dependencies
RUN zypper -n --gpg-auto-import-keys refresh && \
zypper -n install \
rpm-build \
go \
bash-completion \
zsh \
fish \
git \
fdupes

# Set up RPM build directories
RUN mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

ENTRYPOINT ["make", "build-rpm"]
File renamed without changes.
Loading