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
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,21 @@ jobs:
fi

make build
- name: prepare release
run: ./scripts/release/prepare-release.sh
- name: publish
run: |
if [[ "$DRY_RUN" = true ]]; then
./scripts/release/publish-dry-run.sh
else
./scripts/release/publish.sh
fi
- name: release details
run: |
git show -p
ls -1a "$ARTIFACT_DIRECTORY"
- name: commit changes and tag
run: ./scripts/release/commit-and-tag.sh
- name: create tag
run: ./scripts/release/create-tag.sh
- name: create Github release
uses: ncipollo/[email protected]
if: ${{ !inputs.dryRun }}
Expand Down
59 changes: 0 additions & 59 deletions scripts/release/commit-and-tag.sh

This file was deleted.

29 changes: 29 additions & 0 deletions scripts/release/create-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -euo pipefail

release_tag="v${LD_RELEASE_VERSION}"

tag_exists() (
git fetch --tags
git rev-parse "${release_tag}" >/dev/null 2>&1
)

create_tag() (
if tag_exists; then
echo "Tag $release_tag already exists. Aborting."
exit 1
fi

git tag "${release_tag}"
git push origin HEAD
git push origin "${release_tag}"
)

if [[ "$DRY_RUN" == "true" ]]; then
git reset --hard HEAD^
echo "Dry run mode: skipping tag and push"
else
create_tag
fi

43 changes: 23 additions & 20 deletions scripts/release/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ set -euo pipefail

release_tag="v${LD_RELEASE_VERSION}"

stage_artifacts() (
local target=$1

echo "$DOCKER_TOKEN" | sudo docker login --username "$DOCKER_USERNAME" --password-stdin

sudo PATH="$PATH" GITHUB_TOKEN="$GITHUB_TOKEN" make "$target"

mkdir -p "$ARTIFACT_DIRECTORY"
cp ./dist/*.deb ./dist/*.rpm ./dist/*.tar.gz ./dist/*.txt "$ARTIFACT_DIRECTORY"
)

update_go() (
sed -i "s/const Version =.*/const Version = \"${LD_RELEASE_VERSION}\"/g" internal/version/version.go
)
Expand All @@ -34,13 +23,27 @@ update_bitbucket() (
sed -i "s#image: launchdarkly/ld-find-code-refs-bitbucket-pipeline:.*#image: launchdarkly/ld-find-code-refs-bitbucket-pipeline:${LD_RELEASE_VERSION}#g" build/metadata/bitbucket/pipe.yml
)

prepare_release() (
# create artifacts with goreleaser
stage_artifacts $1

# update metadata files
update_go
update_orb
update_gha
update_bitbucket
update_changelog() (
local ts=$(date +"%Y-%m-%d")
# multiline strings don't seem to be supported for GHA inputs, so for now we
# require that the changelog include \n characters for new lines and then we
# just expand them here
# TODO improve this
local changelog_content=$(printf "%b" "$CHANGELOG_ENTRY")
local changelog_entry=$(printf "## [%s] - %s\n%s\n" "$LD_RELEASE_VERSION" "$ts" "$changelog_content")

# insert the new changelog entry (followed by empty line) after line 4
# of CHANGELOG.md
sed -i "4r /dev/stdin" CHANGELOG.md <<< "$changelog_entry"$'\n'
)

update_go
update_orb
update_gha
update_bitbucket
update_changelog

git config user.name "LaunchDarklyReleaseBot"
git config user.email "[email protected]"
git add .
git commit -m "Prepare release ${release_tag}"
4 changes: 2 additions & 2 deletions scripts/release/publish-dry-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -euo pipefail

source $(dirname $0)/prepare_release.sh
prepare_release products-for-release
source $(dirname $0)/stage-artifacts.sh
stage-artifacts 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
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -euo pipefail

source $(dirname $0)/prepare-release.sh
prepare_release publish
source $(dirname $0)/stage-artifacts.sh
stage-artifacts publish

# make bitbucket and github known hosts to push successfully
mkdir -m700 ~/.ssh
Expand Down
14 changes: 14 additions & 0 deletions scripts/release/stage-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euo pipefail

stage_artifacts() (
local target=$1

echo "$DOCKER_TOKEN" | sudo docker login --username "$DOCKER_USERNAME" --password-stdin

sudo PATH="$PATH" GITHUB_TOKEN="$GITHUB_TOKEN" make "$target"

mkdir -p "$ARTIFACT_DIRECTORY"
cp ./dist/*.deb ./dist/*.rpm ./dist/*.tar.gz ./dist/*.txt "$ARTIFACT_DIRECTORY"
)
Loading