Skip to content

Commit

Permalink
OCM-2620 | build: Add files for building releases from Konflux
Browse files Browse the repository at this point in the history
Added Dockerfile to be used from pipeline builds for release generations
using Red Hat keys. Also added some needed modifications and removed old
files related to previous release workflow.

Signed-off-by: Enrique Belarte Luque <[email protected]>
  • Loading branch information
enriquebelarte authored and openshift-merge-bot[bot] committed Jan 25, 2024
1 parent 3bcd6a7 commit 32d3eb4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 122 deletions.
63 changes: 0 additions & 63 deletions .github/workflows/publish-release.yaml

This file was deleted.

59 changes: 0 additions & 59 deletions .goreleaser.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder
COPY . .

ENV GOFLAGS=-buildvcs=false
RUN git config --global --add safe.directory /opt/app-root/src && \
make prepare_release

FROM registry.access.redhat.com/ubi9/ubi-micro:latest
LABEL description="Terraform Provider RHCS"
LABEL io.k8s.description="Terraform Provider RHCS"
LABEL com.redhat.component="terraform-provider-rhcs"
LABEL distribution-scope="release"
LABEL name="terraform-provider-rhcs" release="X.Y" url="https://github.com/terraform-redhat/terraform-provider-rhcs"
LABEL vendor="Red Hat, Inc."
LABEL version="X.Y"

COPY --from=builder /opt/app-root/src/releases /releases
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import_path:=github.com/terraform-redhat/terraform-provider-rhcs
version=$(shell git describe --abbrev=0 | sed 's/^v//' | sed 's/-prerelease\.[0-9]*//')
commit:=$(shell git rev-parse --short HEAD)
git_status:=$(shell git status --porcelain)
REL_VER=$(version)

# Set the linker flags so that the version will be included in the binaries:
ldflags:=\
Expand Down Expand Up @@ -140,3 +141,7 @@ e2e_test: tools install
.PHONY: check-gen
check-gen: generate
scripts/assert_no_diff.sh "generate"

.PHONY: prepare_release
prepare_release:
import_path=${import_path} ldflags="${ldflags}" bash ./build/build_multiarch
31 changes: 31 additions & 0 deletions build/build_multiarch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
archs=(amd64 arm64)
oses=(linux darwin windows)

REL_VER=$(git describe --tags --abbrev=0 | sed "s/v//")
if [[ -z "$REL_VER" ]]; then
echo "Must provide version to prepare release" 1>&2
exit 1
fi
mkdir -p releases

# Manual build release based on Terraform docs.
prepare_release() {
for os in ${oses[@]}
do
for arch in ${archs[@]}
do
if [[ $os == "windows" ]]; then
extension=".exe"
fi
GOOS=${os} GOARCH=${arch} go build -ldflags="${ldflags}" -o /tmp/terraform-provider-rhcs_${os}_${arch}
mv /tmp/terraform-provider-rhcs_${os}_${arch} terraform-provider-rhcs_v${REL_VER}${extension}
zip releases/terraform-provider-rhcs_${REL_VER}_${os}_${arch}.zip CHANGELOG.md LICENSE README.md terraform-provider-rhcs_v${REL_VER}${extension}
rm terraform-provider-rhcs_v${REL_VER}${extension}
cp terraform-registry-manifest.json releases/terraform-provider-rhcs_${REL_VER}_manifest.json
done
done
sha256sum releases/*zip releases/terraform-provider-rhcs_${REL_VER}_manifest.json > releases/terraform-provider-rhcs_${REL_VER}_SHA256SUMS
}

prepare_release

0 comments on commit 32d3eb4

Please sign in to comment.