Skip to content

Commit 76da431

Browse files
committed
Avoid tag clashes when testing the release pipeline
1 parent 0271372 commit 76da431

File tree

4 files changed

+94
-16
lines changed

4 files changed

+94
-16
lines changed

.buildkite/pipeline.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ steps:
587587

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

593593
- label: ⚙️ Windows E2E Tests
@@ -629,6 +629,15 @@ steps:
629629
- ./artifacts/*.tgz
630630
agents:
631631
system: x86_64-linux
632+
633+
- label: Push test image to dockerhub
634+
depends_on: push-dockerhub
635+
commands:
636+
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
637+
agents:
638+
system: x86_64-linux
639+
env:
640+
RELEASE: false
632641

633642
- block: Docker Build
634643
depends_on: []

.buildkite/release.yml

+28-10
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ steps:
7676
env:
7777
RELEASE: false
7878

79+
# - block: Push test image to dockerhub
80+
# key: push-dockerhub
81+
# depends_on: create-release
82+
83+
# - label: Push test image to dockerhub
84+
# depends_on: push-dockerhub
85+
# commands:
86+
# - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
87+
# agents:
88+
# system: x86_64-linux
89+
# env:
90+
# RELEASE: false
91+
7992
- group: Release
8093
depends_on: nightly
8194
if: build.branch == "master"
@@ -123,17 +136,22 @@ steps:
123136
env:
124137
RELEASE: true
125138

126-
- label: Push Docker Image
127-
depends_on:
128-
- create-release
129-
command:
130-
- "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
131-
- "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"
132-
- "./docker-build-push"
133-
agents:
134-
system: x86_64-linux
135-
136139
- label: Update Documentation Links
137140
depends_on: create-release
138141
commands:
139142
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/update-documentation-links.sh
143+
144+
- block: Push to dockerhub
145+
key: push-dockerhub
146+
depends_on: create-release
147+
148+
- label: Push to dockerhub
149+
depends_on: push-dockerhub
150+
artifact_paths:
151+
- ./artifacts/*.tgz
152+
commands:
153+
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
154+
agents:
155+
system: x86_64-linux
156+
env:
157+
RELEASE: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -euox pipefail
4+
5+
base_build=$(buildkite-agent meta-data get base-build)
6+
NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)
7+
8+
if [ "$RELEASE" == "false" ]; then
9+
TAG=nightly
10+
else
11+
TAG=$NEW_GIT_TAG
12+
fi
13+
14+
main_build=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
15+
-X GET "https://api.buildkite.com/v2/builds" \
16+
| jq ".[] | select(.meta_data.\"triggered-by\" == \"$base_build\")" \
17+
| jq .number)
18+
19+
mkdir -p artifacts
20+
21+
artifact() {
22+
local artifact_name=$1
23+
# shellcheck disable=SC2155
24+
local artifact_value=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
25+
-X GET "https://api.buildkite.com/v2/organizations/cardano-foundation/pipelines/cardano-wallet/builds/$main_build/artifacts?per_page=100" \
26+
| jq -r " [.[] | select(.filename == \"$artifact_name\")][0] \
27+
| .download_url")
28+
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" -L \
29+
-o "artifacts/$artifact_name" \
30+
"$artifact_value"
31+
echo "$TAG"
32+
echo "artifacts/$artifact_name"
33+
}
34+
35+
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"

scripts/buildkite/release/release-candidate.sh

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@
33

44
set -euox pipefail
55

6+
if [ "$BUILDKITE_BRANCH" == "master" ]; then
7+
TEST_RC="FALSE"
8+
else
9+
TEST_RC="TRUE"
10+
fi
11+
612
# date from git tag
713
# example v2023-04-04 -> 2023-04-04
814
tag_date() {
915
echo "${1##v}"
1016
}
17+
18+
tag_today() {
19+
sed -e 's/-0/-/g' -e 's/-/./g' <<< "$1"
20+
}
21+
1122
# cabal version from git tag
1223
# example v2023-04-04 -> 2023.4.4
1324
tag_cabal_ver() {
14-
tag_date "$1" | sed -e s/-0/-/g -e s/-/./g
25+
tag_today "$(tag_date "$1")"
1526
}
1627

28+
1729
git tag -l | xargs git tag -d
1830
git fetch --tags
1931

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

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

26-
NEW_GIT_TAG=v$today
38+
if [ $TEST_RC == "TRUE" ]; then
39+
NEW_GIT_TAG="v$today-test"
40+
NEW_CABAL_VERSION=$(tag_today "$today").1
41+
else
42+
NEW_GIT_TAG="v$today"
43+
NEW_CABAL_VERSION=$(tag_today "$today")
44+
fi
45+
2746

28-
NEW_CABAL_VERSION=$(tag_cabal_ver "$NEW_GIT_TAG")
2947

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

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

4866
if [ "$BUILDKITE_BRANCH" == "master" ]; then
4967
RELEASE_CANDIDATE_BRANCH="release-candidate/$NEW_GIT_TAG"
50-
TEST_RC="FALSE"
5168
else
5269
RELEASE_CANDIDATE_BRANCH="test-rc/$BUILDKITE_BRANCH"
53-
TEST_RC="TRUE"
5470
fi
5571

5672
git config --global user.email "[email protected]"

0 commit comments

Comments
 (0)