Skip to content

Commit

Permalink
Avoid tag clashes when testing the release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Jan 9, 2025
1 parent 0271372 commit c3c3543
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 16 deletions.
11 changes: 10 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ steps:

- block: Windows E2E Tests
depends_on: []
if: build.env("RELEASE_CANDIDATE") == null
if: build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE"
key: trigger-windows-e2e-tests

- label: ⚙️ Windows E2E Tests
Expand Down Expand Up @@ -630,6 +630,15 @@ steps:
agents:
system: x86_64-linux

- label: Push test image to dockerhub
depends_on: docker-build
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
agents:
system: x86_64-linux
env:
RELEASE: false

- block: Docker Build
depends_on: []
if: build.env("TEST_RC") == "TRUE"
Expand Down
38 changes: 28 additions & 10 deletions .buildkite/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ steps:
env:
RELEASE: false

# - block: Push test image to dockerhub
# key: push-dockerhub
# depends_on: create-release

# - label: Push test image to dockerhub
# depends_on: push-dockerhub
# commands:
# - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
# agents:
# system: x86_64-linux
# env:
# RELEASE: false

- group: Release
depends_on: nightly
if: build.branch == "master"
Expand Down Expand Up @@ -123,17 +136,22 @@ steps:
env:
RELEASE: true

- label: Push Docker Image
depends_on:
- create-release
command:
- "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
- "nix build .#pushDockerImage --override-input hostNixpkgs \"path:$(nix eval --impure -I $NIX_PATH --expr '(import <nixpkgs> {}).path')\" --override-input customConfig path:./config -o docker-build-push"
- "./docker-build-push"
agents:
system: x86_64-linux

- label: Update Documentation Links
depends_on: create-release
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/update-documentation-links.sh

- block: Push to dockerhub
key: push-dockerhub
depends_on: create-release

- label: Push to dockerhub
depends_on: push-dockerhub
artifact_paths:
- ./artifacts/*.tgz
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
agents:
system: x86_64-linux
env:
RELEASE: true
35 changes: 35 additions & 0 deletions scripts/buildkite/release/push-to-dockerhub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -euox pipefail

base_build=$(buildkite-agent meta-data get base-build)
NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)

if [ "$RELEASE" == "false" ]; then
TAG=nightly
else
TAG=$NEW_GIT_TAG
fi

main_build=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-X GET "https://api.buildkite.com/v2/builds" \
| jq ".[] | select(.meta_data.\"triggered-by\" == \"$base_build\")" \
| jq .number)

mkdir -p artifacts

artifact() {
local artifact_name=$1
# shellcheck disable=SC2155
local artifact_value=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-X GET "https://api.buildkite.com/v2/organizations/cardano-foundation/pipelines/cardano-wallet/builds/$main_build/artifacts?per_page=100" \
| jq -r " [.[] | select(.filename == \"$artifact_name\")][0] \
| .download_url")
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" -L \
-o "artifacts/$artifact_name" \
"$artifact_value"
echo "$TAG"
echo "artifacts/$artifact_name"
}

artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"
26 changes: 21 additions & 5 deletions scripts/buildkite/release/release-candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@

set -euox pipefail

if [ "$BUILDKITE_BRANCH" == "master" ]; then
TEST_RC="FALSE"
else
TEST_RC="TRUE"
fi

# date from git tag
# example v2023-04-04 -> 2023-04-04
tag_date() {
echo "${1##v}"
}

tag_today() {
sed -e 's/-0/-/g' -e 's/-/./g' <<< "$1"
}

# cabal version from git tag
# example v2023-04-04 -> 2023.4.4
tag_cabal_ver() {
tag_date "$1" | sed -e s/-0/-/g -e s/-/./g
tag_today "$(tag_date "$1")"
}


git tag -l | xargs git tag -d
git fetch --tags

Expand All @@ -23,9 +35,15 @@ git checkout "$BASE_COMMIT"

today=$(date +%Y-%m-%d)

NEW_GIT_TAG=v$today
if [ $TEST_RC == "TRUE" ]; then
NEW_GIT_TAG="v$today-test"
NEW_CABAL_VERSION=$(tag_today "$today").1
else
NEW_GIT_TAG="v$today"
NEW_CABAL_VERSION=$(tag_today "$today")
fi


NEW_CABAL_VERSION=$(tag_cabal_ver "$NEW_GIT_TAG")

OLD_GIT_TAG=$( git tag -l "v2*-*-*" | sort | tail -n1)

Expand All @@ -47,10 +65,8 @@ CARDANO_NODE_TAG=$(cardano-node version | head -n1 | awk '{print $2}')

if [ "$BUILDKITE_BRANCH" == "master" ]; then
RELEASE_CANDIDATE_BRANCH="release-candidate/$NEW_GIT_TAG"
TEST_RC="FALSE"
else
RELEASE_CANDIDATE_BRANCH="test-rc/$BUILDKITE_BRANCH"
TEST_RC="TRUE"
fi

git config --global user.email "[email protected]"
Expand Down

0 comments on commit c3c3543

Please sign in to comment.