Skip to content

Commit

Permalink
Release: add static binaries
Browse files Browse the repository at this point in the history
Fix issue 7296

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Nov 11, 2022
1 parent 02484f5 commit 4a36102
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
export CC=$(xx-info)-gcc && xx-go --wrap && \
make release cri-release cri-cni-release && \
make release static-release cri-release cri-cni-release && \
for f in $(find bin -executable -type f); do xx-verify $f; done

# check git working tree after build
Expand Down
35 changes: 29 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ WHALE = "🇩"
ONI = "👹"

RELEASE=containerd-$(VERSION:v%=%)-${GOOS}-${GOARCH}
STATICRELEASE=containerd-static-$(VERSION:v%=%)-${GOOS}-${GOARCH}
CRIRELEASE=cri-containerd-$(VERSION:v%=%)-${GOOS}-${GOARCH}
CRICNIRELEASE=cri-containerd-cni-$(VERSION:v%=%)-${GOOS}-${GOARCH}

Expand Down Expand Up @@ -148,7 +149,7 @@ GOTEST ?= $(GO) test
OUTPUTDIR = $(join $(ROOTDIR), _output)
CRIDIR=$(OUTPUTDIR)/cri

.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install uninstall vendor release mandir install-man genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install uninstall vendor release static-release mandir install-man genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test
.DEFAULT: default

# Forcibly set the default goal to all, in case an include above brought in a rule definition.
Expand Down Expand Up @@ -299,18 +300,40 @@ install-man: man
$(foreach manpage,$(addprefix man/,$(MANPAGES)), $(call installmanpage,$(manpage),$(subst .,,$(suffix $(manpage))),$(notdir $(manpage))))


define pack_release
@rm -rf releases/$(1) releases/$(1).tar.gz
@$(INSTALL) -d releases/$(1)/bin
@$(INSTALL) $(BINARIES) releases/$(1)/bin
@tar -czf releases/$(1).tar.gz -C releases/$(1) bin
@rm -rf releases/$(1)
endef


releases/$(RELEASE).tar.gz: $(BINARIES)
@echo "$(WHALE) $@"
@rm -rf releases/$(RELEASE) releases/$(RELEASE).tar.gz
@$(INSTALL) -d releases/$(RELEASE)/bin
@$(INSTALL) $(BINARIES) releases/$(RELEASE)/bin
@tar -czf releases/$(RELEASE).tar.gz -C releases/$(RELEASE) bin
@rm -rf releases/$(RELEASE)
$(call pack_release,$(RELEASE))

release: releases/$(RELEASE).tar.gz
@echo "$(WHALE) $@"
@cd releases && sha256sum $(RELEASE).tar.gz >$(RELEASE).tar.gz.sha256sum

releases/$(STATICRELEASE).tar.gz:
ifeq ($(GOOS),linux)
@make STATIC=1 $(BINARIES)
@echo "$(WHALE) $@"
$(call pack_release,$(STATICRELEASE))
else
@echo "Skipping $(STATICRELEASE) for $(GOOS)"
endif

static-release: releases/$(STATICRELEASE).tar.gz
ifeq ($(GOOS),linux)
@echo "$(WHALE) $@"
@cd releases && sha256sum $(STATICRELEASE).tar.gz >$(STATICRELEASE).tar.gz.sha256sum
else
@echo "Skipping releasing $(STATICRELEASE) for $(GOOS)"
endif

# install of cri deps into release output directory
ifeq ($(GOOS),windows)
install-cri-deps: $(BINARIES)
Expand Down
14 changes: 14 additions & 0 deletions releases/v1.7.0-beta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,17 @@ The 2.0 release will remove any feature deprecated in 1.x. Features deprecated i
* **Add NoSameOwner option when unpacking tars** ([#7386](https://github.com/containerd/containerd/pull/7386))
See the changelog for complete list of changes"""

# postface requires release-tool >= 1.1
postface = """\
### Which file should I download?
* `containerd-<VERSION>-<OS>-<ARCH>.tar.gz`: ✅Recommended. Dynamically linked with glibc 2.27 (Ubuntu 18.04).
* `containerd-static-<VERSION>-<OS>-<ARCH>.tar.gz`: Statically linked. Expected to be used on non-glibc Linux distributions. Not position-independent.
* `cri-containerd-<VERSION>-<OS>-<ARCH>.tar.gz`: (Deprecated)
* `cri-containerd-cni-<VERSION>-<OS>-<ARCH>.tar.gz`: (Deprecated)
In addition to containerd, typically you will have to install [runc](https://github.com/opencontainers/runc/releases)
and [CNI plugins](https://github.com/containernetworking/plugins/releases) from their official sites too.
See also the [Getting Started](https://github.com/containerd/containerd/blob/main/docs/getting-started.md) documentation.
"""

0 comments on commit 4a36102

Please sign in to comment.