mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Converge local and cloud gorelease scripts, improve release notes
This commit is contained in:
@@ -1,131 +1,32 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Usage (from top of repo):
|
||||
# This script is called by Kustomize's Cloud Build release pipeline.
|
||||
# It installs jq (required for release note construction)
|
||||
# and then runs goreleaser (http://goreleaser.com).
|
||||
#
|
||||
# releasing/cloudbuild.sh TAG [--snapshot]
|
||||
# To test it locally, run it in a goreleaser container:
|
||||
#
|
||||
# Where TAG is in the form
|
||||
# # Get goreleaser image from cloudbuild.yaml
|
||||
# export GORELEASER_IMAGE=goreleaser/goreleaser:v0.179.0
|
||||
#
|
||||
# api/v1.2.3
|
||||
# kustomize/v1.2.3
|
||||
# cmd/config/v1.2.3
|
||||
# ... etc.
|
||||
# # Drop into a shell
|
||||
# docker run -it --entrypoint=/bin/bash -v $(pwd):/go/src/github.com/kubernetes-sigs/kustomize -w /go/src/github.com/kubernetes-sigs/kustomize $GORELEASER_IMAGE
|
||||
#
|
||||
# Cloud build should be configured to trigger on tags
|
||||
# matching:
|
||||
# # Run this script in the container, where $TAG is the tag to "release" (e.g. kyaml/v0.13.4)
|
||||
# ./releasing/cloudbuild.sh $TAG --snapshot
|
||||
#
|
||||
# [\w/]+/v\d+\.\d+\.\d+
|
||||
#
|
||||
# This script runs goreleaser (http://goreleaser.com),
|
||||
# presumably from a cloudbuild.yaml step that installed it.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
fullTag=$1
|
||||
shift
|
||||
echo "fullTag=$fullTag"
|
||||
|
||||
remainingArgs="$@"
|
||||
echo "Remaining args: $remainingArgs"
|
||||
|
||||
# Take everything before the last slash.
|
||||
# This is expected to match $module.
|
||||
module=${fullTag%/*}
|
||||
echo "module=$module"
|
||||
|
||||
# Find previous tag that matches the tags module
|
||||
prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains=$fullTag | head -n 1)
|
||||
|
||||
# Generate the changelog for this release
|
||||
# using the last two tags for the module
|
||||
changeLogFile=$(mktemp)
|
||||
git log $prevTag..$fullTag \
|
||||
--pretty=oneline \
|
||||
--abbrev-commit --no-decorate --no-color --no-merges \
|
||||
-- $module > $changeLogFile
|
||||
echo "Release notes:"
|
||||
cat $changeLogFile
|
||||
|
||||
# Take everything after the last slash.
|
||||
# This should be something like "v1.2.3".
|
||||
semVer=`echo $fullTag | sed "s|$module/||"`
|
||||
echo "semVer=$semVer"
|
||||
|
||||
# This is probably a directory called /workspace
|
||||
echo "pwd = $PWD"
|
||||
|
||||
# Sanity check
|
||||
echo "### ls -las . ################################"
|
||||
ls -las .
|
||||
echo "###################################"
|
||||
|
||||
|
||||
# CD into the module directory.
|
||||
# This directory expected to contain a main.go, so there's
|
||||
# no need for extra details in the `build` stanza below.
|
||||
cd $module
|
||||
|
||||
skipBuild=true
|
||||
if [[ "$module" == "kustomize" || "$module" == "pluginator" ]]; then
|
||||
# If releasing a main program, don't skip the build.
|
||||
skipBuild=false
|
||||
if ! command -v jq &> /dev/null
|
||||
then
|
||||
# This assumes we are in an alpine container (which is the case for goreleaser images)
|
||||
echo "Installing jq."
|
||||
apk add jq --no-cache
|
||||
fi
|
||||
|
||||
goReleaserConfigFile=$(mktemp)
|
||||
|
||||
cat <<EOF >$goReleaserConfigFile
|
||||
project_name: $module
|
||||
|
||||
archives:
|
||||
- name_template: "${module}_${semVer}_{{ .Os }}_{{ .Arch }}"
|
||||
|
||||
builds:
|
||||
- skip: $skipBuild
|
||||
|
||||
ldflags: >
|
||||
-s
|
||||
-X sigs.k8s.io/kustomize/api/provenance.version={{.Version}}
|
||||
-X sigs.k8s.io/kustomize/api/provenance.gitCommit={{.Commit}}
|
||||
-X sigs.k8s.io/kustomize/api/provenance.buildDate={{.Date}}
|
||||
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- s390x
|
||||
- ppc64le
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
- GO111MODULE=on
|
||||
|
||||
release:
|
||||
github:
|
||||
owner: kubernetes-sigs
|
||||
name: kustomize
|
||||
draft: true
|
||||
|
||||
EOF
|
||||
|
||||
cat $goReleaserConfigFile
|
||||
|
||||
date
|
||||
|
||||
time /usr/local/bin/goreleaser release \
|
||||
--debug \
|
||||
--timeout 10m \
|
||||
--parallelism 7 \
|
||||
--config=$goReleaserConfigFile \
|
||||
--release-notes=$changeLogFile \
|
||||
--rm-dist \
|
||||
--skip-validate $remainingArgs
|
||||
|
||||
date
|
||||
./releasing/run-goreleaser.sh "$fullTag" release "$@"
|
||||
|
||||
Reference in New Issue
Block a user