Skip to content

Commit b9e2321

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

File tree

4 files changed

+115
-32
lines changed

4 files changed

+115
-32
lines changed

Diff for: .buildkite/pipeline.yml

+19-17
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ steps:
541541
build.branch !~ /^gh-readonly-queue\/master/
542542
&& build.branch != "master"
543543
&& build.branch != "rc-latest"
544-
&& build.env("RELEASE_CANDIDATE") == null
544+
&& (build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE")
545545
key: trigger-build-windows-artifacts
546546

547547
- label: Build Package (windows)
@@ -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
@@ -630,21 +630,23 @@ steps:
630630
agents:
631631
system: x86_64-linux
632632

633-
- block: Docker Build
634-
depends_on: []
635-
if: build.env("TEST_RC") == "TRUE"
636-
key: docker-build-block
637-
638-
- label: Push Docker Image
639-
depends_on:
640-
- docker-build
641-
key: build-docker
642-
command:
643-
- "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
644-
- "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"
645-
- "./docker-build-push"
646-
agents:
647-
system: x86_64-linux
633+
634+
635+
# - block: Docker Build
636+
# depends_on: []
637+
# if: build.env("TEST_RC") == "TRUE"
638+
# key: docker-build-block
639+
640+
# - label: Push Docker Image
641+
# depends_on:
642+
# - docker-build
643+
# key: build-docker
644+
# command:
645+
# - "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
646+
# - "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"
647+
# - "./docker-build-push"
648+
# agents:
649+
# system: x86_64-linux
648650

649651
- group: Docker Checks
650652
depends_on:

Diff for: .buildkite/release.yml

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

79+
- label: Push test image to dockerhub
80+
commands:
81+
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
82+
agents:
83+
system: x86_64-linux
84+
env:
85+
RELEASE: false
86+
TAG: nightly
87+
88+
# - block: Push test image to dockerhub
89+
# key: push-dockerhub
90+
# depends_on: create-release
91+
92+
# - label: Push test image to dockerhub
93+
# depends_on: push-dockerhub
94+
# commands:
95+
# - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
96+
# agents:
97+
# system: x86_64-linux
98+
# env:
99+
# RELEASE: false
100+
79101
- group: Release
80102
depends_on: nightly
81103
if: build.branch == "master"
@@ -123,17 +145,22 @@ steps:
123145
env:
124146
RELEASE: true
125147

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-
136148
- label: Update Documentation Links
137149
depends_on: create-release
138150
commands:
139151
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/update-documentation-links.sh
152+
153+
- block: Push to dockerhub
154+
key: push-dockerhub
155+
depends_on: create-release
156+
157+
- label: Push to dockerhub
158+
depends_on: push-dockerhub
159+
artifact_paths:
160+
- ./artifacts/*.tgz
161+
commands:
162+
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
163+
agents:
164+
system: x86_64-linux
165+
env:
166+
RELEASE: true

Diff for: scripts/buildkite/release/push-to-dockerhub.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -euox pipefail
4+
5+
TRIGGERED_BY=$(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=$TAG
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\" == \"$TRIGGERED_BY\")" \
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+
local image_name="cardanofoundation/cardano-wallet:$TAG"
32+
docker login -u cfhal -p "$DOCKER_HUB_TOKEN"
33+
docker load -i "artifacts/$artifact_name"
34+
docker push "cardanofoundation/cardano-wallet:$TAG"
35+
echo "$image_name"
36+
}
37+
38+
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"

Diff for: 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)