From 867be2ca9a8727a0572ba3c4109b47acc9d540dd Mon Sep 17 00:00:00 2001 From: Casey Waldren Date: Mon, 12 Feb 2024 10:28:22 -0800 Subject: [PATCH] chore(v7): remove releaser configuration (#299) This commit removes the `.ldrelease` directory. The release process is replaced with `release-please` Github Action. --- .ldrelease/build.sh | 7 ---- .ldrelease/config.yml | 53 ---------------------------- .ldrelease/prepare.sh | 6 ---- .ldrelease/publish-dry-run.sh | 12 ------- .ldrelease/publish.sh | 6 ---- .ldrelease/run-publish-target.sh | 27 -------------- .ldrelease/secrets.properties | 6 ---- .ldrelease/update-version.sh | 8 ----- Dockerfile.goreleaser | 2 -- scripts/update-go-release-version.sh | 9 ++--- scripts/verify-release-versions.sh | 16 ++------- 11 files changed, 4 insertions(+), 148 deletions(-) delete mode 100755 .ldrelease/build.sh delete mode 100644 .ldrelease/config.yml delete mode 100755 .ldrelease/prepare.sh delete mode 100755 .ldrelease/publish-dry-run.sh delete mode 100755 .ldrelease/publish.sh delete mode 100755 .ldrelease/run-publish-target.sh delete mode 100644 .ldrelease/secrets.properties delete mode 100755 .ldrelease/update-version.sh diff --git a/.ldrelease/build.sh b/.ldrelease/build.sh deleted file mode 100755 index 17fc770f..00000000 --- a/.ldrelease/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -set -ue - -make build diff --git a/.ldrelease/config.yml b/.ldrelease/config.yml deleted file mode 100644 index ba518f2d..00000000 --- a/.ldrelease/config.yml +++ /dev/null @@ -1,53 +0,0 @@ - -# Configuration for releasing ld-relay using the Releaser tool. -# -# The flow is as follows: -# -# 1. Releaser starts a Golang Docker container, using the Docker image that is -# specified below. That's what determines the version of Go we're building with. -# -# 2. Releaser obtains any necessary credentials specified in secrets.properties. -# -# 3. Releaser runs update-version.sh to update the version string in the source -# source code. -# -# 4. Releaser runs prepare.sh, build.sh, and publish.sh. -# -# 5. From publish.sh, we execute a Makefile target that runs Goreleaser. -# Goreleaser, using the configuration in .goreleaser.yml, builds the ld-relay -# binary for the default Linux architecture (in the project root directory). -# It also builds binaries for other platforms (as archives and/or package files) -# in a "dist" subdirectory. -# -# 6. Goreleaser builds a Docker image, using the configuration in -# Dockerfile.goreleaser. Note that Dockerfile.goreleaser does not include any -# build steps for Relay, because the ld-relay binary has already been built; it -# just copies that binary into the image. -# -# 7. Goreleaser pushes the Docker image to DockerHub. -# -# 8. In run-publish-target.sh (called from publish.sh) we copy the binaries from -# "dist" into a special location that will cause Releaser to attach them to the -# GitHub release it creates. - -version: 2 - -repo: - public: ld-relay - private: ld-relay-private - -jobs: - - docker: - image: cimg/go:1.21.6 # See "Runtime platform versions" in CONTRIBUTING.md - copyGitHistory: true - template: - name: go - -branches: - - name: v7 - - name: v6 - - name: v5 - -publications: - - url: https://pkg.go.dev/github.com/launchdarkly/ld-relay - description: documentation diff --git a/.ldrelease/prepare.sh b/.ldrelease/prepare.sh deleted file mode 100755 index 0ac46216..00000000 --- a/.ldrelease/prepare.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -sudo apt-get -q update -sudo apt-get -y install rpm diff --git a/.ldrelease/publish-dry-run.sh b/.ldrelease/publish-dry-run.sh deleted file mode 100755 index d91dcec6..00000000 --- a/.ldrelease/publish-dry-run.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -# The "products-for-release" makefile target does a goreleaser build but doesn't push to DockerHub -$(dirname $0)/run-publish-target.sh products-for-release - -# Copy the Docker image that goreleaser just built into the artifacts - we only do -# this in a dry run, because in a real release the image will be available from -# DockerHub anyway so there's no point in attaching it to the release. -image_archive_name=ld-relay-docker-image.tar.gz -sudo docker save launchdarkly/ld-relay:${LD_RELEASE_VERSION} | gzip >${LD_RELEASE_ARTIFACTS_DIR}/${image_archive_name} diff --git a/.ldrelease/publish.sh b/.ldrelease/publish.sh deleted file mode 100755 index b66f9716..00000000 --- a/.ldrelease/publish.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -# the "publish" makefile target pushes the image to Docker -$(dirname $0)/run-publish-target.sh publish diff --git a/.ldrelease/run-publish-target.sh b/.ldrelease/run-publish-target.sh deleted file mode 100755 index 5b602d22..00000000 --- a/.ldrelease/run-publish-target.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -# Called from publish.sh or publish-dry-run.sh - parameter is the Makefile target to run -TARGET=$1 - -# Note that Docker commands in this script are being sudo'd. That's because we are -# already running inside a container, and rather than trying to run a whole nested -# Docker daemon inside that container, we are sharing the host's Docker daemon. But -# the mechanism for doing so involves sharing a socket path (docker.sock) that is -# only accessible by root. - -# Doing a Docker login is only relevant if we're doing a real release rather than a -# dry run, but we'll still do it even if it's a dry run, because that proves that -# our credentials are right so a release would theoretically succeed. -docker_username="$(cat "${LD_RELEASE_SECRETS_DIR}/docker_username")" -cat "${LD_RELEASE_SECRETS_DIR}/docker_token" | sudo docker login --username "${docker_username}" --password-stdin - -sudo PATH=$PATH make $TARGET - -# Goreleaser puts all the artifacts in ./dist - copying them to $LD_RELEASE_ARTIFACTS_DIR -# causes Releaser to pick them up and attach them to the release in GitHub. However, don't -# copy every file from ./dist because Goreleaser also puts temporary build products there -# that we don't want. -mkdir -p ./artifacts -cp ./dist/*.deb ./dist/*.rpm ./dist/*.tar.gz ./dist/*.txt ${LD_RELEASE_ARTIFACTS_DIR} diff --git a/.ldrelease/secrets.properties b/.ldrelease/secrets.properties deleted file mode 100644 index 1036d63e..00000000 --- a/.ldrelease/secrets.properties +++ /dev/null @@ -1,6 +0,0 @@ - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -# Tells Releaser where to find the credentials we use during releases. -docker_username=param:/global/services/docker/public/username -docker_token=param:/global/services/docker/public/token diff --git a/.ldrelease/update-version.sh b/.ldrelease/update-version.sh deleted file mode 100755 index cf463cd5..00000000 --- a/.ldrelease/update-version.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# See comments in .ldrelease/config.yml for an explanation of the build/release process. - -VERSION_GO=relay/version/version.go -VERSION_GO_TEMP=${VERSION_GO}.tmp -sed "s/const Version =.*/const Version = \"${LD_RELEASE_VERSION}\"/g" ${VERSION_GO} > ${VERSION_GO_TEMP} -mv ${VERSION_GO_TEMP} ${VERSION_GO} diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser index 61dd2c57..3d9fd1ee 100644 --- a/Dockerfile.goreleaser +++ b/Dockerfile.goreleaser @@ -1,7 +1,5 @@ # This is the Dockerfile used for release (published to dockerhub by goreleaser) -# See .ldrelease/config.yml for an explanation of the build/release process. - FROM alpine:3.19.0 # See "Runtime platform versions" in CONTRIBUTING.md diff --git a/scripts/update-go-release-version.sh b/scripts/update-go-release-version.sh index af31dac6..61bed1e4 100755 --- a/scripts/update-go-release-version.sh +++ b/scripts/update-go-release-version.sh @@ -15,7 +15,6 @@ fi cd $(dirname $0)/.. -ldrelease_config_file=.ldrelease/config.yml github_config_file=.github/variables/go-versions.env dockerfile_for_tests=Dockerfile @@ -24,17 +23,13 @@ function ensure_file_was_changed() { if (( $(diff ${filename} ${filename}.tmp | grep '^>' | wc -l) < 1 )); then echo "failed to update Go version in ${filename}; sed expression did not match any lines or matched more than one line" diff ${filename} ${filename}.tmp || true - for f in ${ldrelease_config_file} ${github_config_file} ${dockerfile_for_tests}; do + for f in ${github_config_file} ${dockerfile_for_tests}; do rm -r ${f}.tmp done exit 1 fi } -sed <${ldrelease_config_file} >${ldrelease_config_file}.tmp \ - -e "/image:/s#cimg/go:[^ ]*#cimg/go:${LATEST_VERSION}#" -ensure_file_was_changed ${ldrelease_config_file} - sed <${github_config_file} >${github_config_file}.tmp \ -e "s#latest=[^ ]*#latest=${LATEST_VERSION}#g" \ -e "s#penultimate=[^ ]*#penultimate=${PENULTIMATE_VERSION}#g" @@ -44,7 +39,7 @@ sed <${dockerfile_for_tests} >${dockerfile_for_tests}.tmp \ -e "s#FROM *golang:[^-]*#FROM golang:${LATEST_VERSION}#" ensure_file_was_changed ${dockerfile_for_tests} -for f in ${ldrelease_config_file} ${github_config_file} ${dockerfile_for_tests}; do +for f in ${github_config_file} ${dockerfile_for_tests}; do mv ${f}.tmp ${f} echo "updated ${f}" done diff --git a/scripts/verify-release-versions.sh b/scripts/verify-release-versions.sh index 332ae7f7..447cfe1e 100755 --- a/scripts/verify-release-versions.sh +++ b/scripts/verify-release-versions.sh @@ -3,15 +3,11 @@ # verify-release-versions.sh (no parameters) # This script checks all of the configuration files where a Go version and/or Alpine version is # mentioned in the context of producing releases, and makes sure they are consistent with each other. -# Unfortunately it's not possible to have these be sourced from just one file, because the CircleCI -# configuration and the .ldrelease configuration require Docker image names to be hard-coded in their -# respective config files. set -e cd $(dirname $0)/.. -ldrelease_config_file=.ldrelease/config.yml github_config_file=.github/variables/go-versions.env dockerfile_for_tests=Dockerfile dockerfile_for_releases=Dockerfile.goreleaser @@ -21,12 +17,6 @@ function fail_for_file() { exit 1 } -LDRELEASE_GO_VERSION=$(sed <${ldrelease_config_file} -n 's#.*image: *cimg/go:\([0-9.]*\).*#\1#p') -if [ -z "${LDRELEASE_GO_VERSION}" ]; then - fail_for_file Go ${ldrelease_config_file} -fi -echo "${ldrelease_config_file} (for building releases) is using Go ${LDRELEASE_GO_VERSION}" - GITHUB_GO_VERSION=$(sed <${github_config_file} -n 's/^latest=\(.*\)$/\1/p') if [ -z "${GITHUB_GO_VERSION}" ]; then fail_for_file Go ${github_config_file} @@ -39,8 +29,7 @@ if [ -z "${DOCKERFILE_TESTS_GO_VERSION}" ]; then fi echo "${dockerfile_for_tests} (for images in CI tests) is using Go ${DOCKERFILE_TESTS_GO_VERSION}" -if [[ "${GITHUB_GO_VERSION}" != "${LDRELEASE_GO_VERSION}" || \ - "${DOCKERFILE_TESTS_GO_VERSION}" != "${LDRELEASE_GO_VERSION}" ]]; then +if [[ "${GITHUB_GO_VERSION}" != "${DOCKERFILE_TESTS_GO_VERSION}" ]]; then echo; echo "Go versions are out of sync!" exit 1 fi @@ -77,9 +66,8 @@ echo "Alpine versions are in sync" echo "Checking availability of Docker images..." for docker_image in \ - "cimg/go:${LDRELEASE_GO_VERSION}" \ "alpine:${DOCKERFILE_RELEASES_ALPINE_VERSION}" \ - "golang:${LDRELEASE_GO_VERSION}-alpine${DOCKERFILE_TESTS_ALPINE_MINOR_VERSION}" + "golang:${GITHUB_GO_VERSION}-alpine${DOCKERFILE_TESTS_ALPINE_MINOR_VERSION}" do echo -n " ${docker_image}... " docker pull ${docker_image} >/dev/null 2>/dev/null || { echo; echo "not available!"; exit 1; }