diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 9eb483e7158..b47630aef7b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -510,11 +510,12 @@ steps: if: | build.branch !~ /^gh-readonly-queue\/master/ && build.branch != "master" - && ( build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE" ) + && build.env("RELEASE_CANDIDATE") == null key: block-macos - label: Build Integration Tests (macOS, arm64) key: macos-arm64-tests-build-integration + if: build.env("TEST_RC") == null || build.env("TEST_RC") == "FALSE" depends_on: block-macos command: nix build -L .#packages.aarch64-darwin.integration-exe agents: @@ -610,10 +611,8 @@ steps: if: | build.branch !~ /^gh-readonly-queue\/master/ && build.branch != "master" - && (build.env("RELEASE_CANDIDATE") == null - || build.env("TEST_RC") == "TRUE" - ) && build.branch != "rc-latest" + && build.env("RELEASE_CANDIDATE") == null key: trigger-build-windows-artifacts - label: Build Package (windows) @@ -627,6 +626,7 @@ steps: - label: Build Testing Bundle (windows) key: windows-testing-bundle + if: build.env("TEST_RC") == null || build.env("TEST_RC") == "FALSE" depends_on: - trigger-build-windows-artifacts command: nix build -o result/windows-tests .#ci.artifacts.win64.tests @@ -635,7 +635,7 @@ steps: system: ${linux} - label: Tag as Release Candidate (windows) - if: build.env("RELEASE_CANDIDATE") != null + if: build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "FALSE" depends_on: - windows-package - windows-testing-bundle @@ -650,14 +650,8 @@ steps: - linux-artifacts steps: - - block: Docker Build - depends_on: [] - if: build.env("TEST_RC") == "TRUE" - key: docker-build-block - - label: Build Docker Image key: docker-build - depends_on: docker-build-block commands: ./scripts/buildkite/main/docker-build.sh artifact_paths: @@ -665,6 +659,11 @@ steps: agents: system: x86_64-linux + - block: Docker Build + depends_on: [] + if: build.env("TEST_RC") == "TRUE" + key: docker-build-block + - label: Push Docker Image depends_on: - docker-build diff --git a/.buildkite/release.yml b/.buildkite/release.yml index bdf546b46c7..ad914e0e401 100644 --- a/.buildkite/release.yml +++ b/.buildkite/release.yml @@ -24,22 +24,63 @@ steps: commands: - ./scripts/buildkite/release/generate-trigger.sh | buildkite-agent pipeline upload - - label: Push swagger daily - depends_on: main-pipeline-build + - label: Collect changes + key: collect-changes + depends_on: add-release-commits commands: - - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-bump.sh - artifacts: - - artifacts/api-diffs.md - env: - RELEASE: false + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/make_changelog.sh agents: system: x86_64-linux + artifacts: + - artifacts/changes.md + + - group : Nightly + key: nightly + depends_on: main-pipeline-build + steps: + - label: Push swagger nightly + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-bump.sh + artifacts: + - artifacts/api-diffs.md + env: + RELEASE: false + agents: + system: x86_64-linux + + - label: Push nightly release tag + key: push-nightly-tag + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-tag.sh + agents: + system: x86_64-linux + env: + RELEASE: false + + - label: Push nightly release + depends_on: push-nightly-tag + key: push-nightly-release + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-release.sh + agents: + system: x86_64-linux + env: + RELEASE: false + + - label: Push nightly release artifacts + depends_on: push-nightly-release + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-artifacts.sh + agents: + system: x86_64-linux + env: + RELEASE: false - group: Release - if: build.branch =~ /^release-candidate/ + depends_on: nightly + if: build.branch == "master" steps: - block: Create a release - depends_on: main-pipeline-build key: create-release - label: Push swagger release @@ -51,4 +92,33 @@ steps: env: RELEASE: true agents: - system: x86_64-linux \ No newline at end of file + system: x86_64-linux + + - label: Push release tag + key: push-release-tag + depends_on: create-release + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-tag.sh + agents: + system: x86_64-linux + env: + RELEASE: true + + - label: Push release + depends_on: push-release-tag + key: push-release + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-release.sh + agents: + system: x86_64-linux + env: + RELEASE: true + + - label: Push release artifacts + depends_on: push-release + commands: + - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-artifacts.sh + agents: + system: x86_64-linux + env: + RELEASE: true diff --git a/scripts/buildkite/release/flake.nix b/scripts/buildkite/release/flake.nix index 4048e3054dd..d8f4dc1d580 100644 --- a/scripts/buildkite/release/flake.nix +++ b/scripts/buildkite/release/flake.nix @@ -32,6 +32,8 @@ pkgs.gnutar pkgs.gnupg pkgs.nodejs_22 + pkgs.gh + pkgs.gettext ]; shellHook = '' # use this hook to set up additional environment variables diff --git a/scripts/buildkite/release/generate-trigger.sh b/scripts/buildkite/release/generate-trigger.sh index cb9c7e0d003..743ead0f1ad 100755 --- a/scripts/buildkite/release/generate-trigger.sh +++ b/scripts/buildkite/release/generate-trigger.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#! /usr/bin/env bash set -euo pipefail @@ -7,6 +7,13 @@ VERSION=$(buildkite-agent meta-data get "release-version") BRANCH=$(buildkite-agent meta-data get "release-candidate-branch") CABAL=$(buildkite-agent meta-data get "release-cabal-version") TEST_RC=$(buildkite-agent meta-data get "test-rc") +BASE_BUILD=$(buildkite-agent meta-data get "base-build") + +if [ "$TEST_RC" == "TRUE" ]; then + title="Test Release Candidate of $VERSION" +else + title="Release Candidate of $VERSION" +fi cat << YAML steps: @@ -17,7 +24,7 @@ steps: build: commit: $COMMIT branch: $BRANCH - message: Release Candidate of $VERSION + message: $title env: RELEASE_CANDIDATE: "$VERSION" TEST_RC: "$TEST_RC" @@ -26,5 +33,6 @@ steps: release-candidate-commit: "$COMMIT" release-candidate-branch: "$BRANCH" release-cabal-version: "$CABAL" + triggered-by: "$BASE_BUILD" YAML diff --git a/scripts/buildkite/release/make_changelog.sh b/scripts/buildkite/release/make_changelog.sh new file mode 100755 index 00000000000..52fe75c80da --- /dev/null +++ b/scripts/buildkite/release/make_changelog.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +since_date="$(buildkite-agent meta-data get last-release-date)" + +fetch_prs() { + curl --silent \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/search/issues?q=repo:cardano-foundation/cardano-wallet+is:pr+is:merged+merged:%3E$since_date" + } + +prs=$(fetch_prs | jq '.items | map({date:.pull_request.merged_at | split("T")[0], number:.number,title:.title,labels:.labels| map(.name),author:.user.login })') + +items=$(jq 'map("\(.date), #\(.number), \(.author), \(.labels | join(", ")), \(.title)")' <<< "$prs") +item_max=$(jq 'length - 1' <<< "$items") + +mkdir -p artifacts + +for i in $(seq 0 "$item_max"); do + item=$(jq -r ".[$i]" <<< "$items") + echo "$item" \ + | sed -E 's,\[(ADP\-[0-9]+)\],[\1](https://cardanofoundation.atlassian.net/browse/\1),g' \ + | sed -E 's,\[ADP-x+\],,g' \ + | sed -E 's,#([0-9]+),[#\1](https://github.com/cardano-foundation/cardano-wallet/pull/\1),g' \ + >> artifacts/changes.md +done diff --git a/scripts/buildkite/release/push-artifacts.sh b/scripts/buildkite/release/push-artifacts.sh new file mode 100755 index 00000000000..f2d6671b1d2 --- /dev/null +++ b/scripts/buildkite/release/push-artifacts.sh @@ -0,0 +1,38 @@ +#! /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" \ + | jq -r ".[] | select(.filename == \"$artifact_name\") \ + | .download_url") + curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" -L \ + -o "artifacts/$artifact_name" \ + "$artifact_value" + gh release upload "$TAG" "artifacts/$artifact_name" +} + +artifact "cardano-wallet-$NEW_GIT_TAG-linux64.tar.gz" +artifact "cardano-wallet.exe-$NEW_GIT_TAG-win64.zip" +artifact "cardano-wallet-$NEW_GIT_TAG-macos-silicon.tar.gz" +artifact "cardano-wallet-$NEW_GIT_TAG-macos-intel.tar.gz" +artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz" diff --git a/scripts/buildkite/release/push-release.sh b/scripts/buildkite/release/push-release.sh new file mode 100755 index 00000000000..e621820edd4 --- /dev/null +++ b/scripts/buildkite/release/push-release.sh @@ -0,0 +1,41 @@ +#! /usr/bin/env bash + +set -euox pipefail + +NEW_GIT_TAG=$(buildkite-agent meta-data get release-version) + +if [ "$RELEASE" == "false" ]; then + TAG=nightly + title="Nightly $NEW_GIT_TAG" +else + TAG=$NEW_GIT_TAG + title="Release $TAG" +fi + +buildkite-agent artifact download artifacts/changes.md . +# shellcheck disable=SC2155 +export CHANGES=$(cat artifacts/changes.md) + +# shellcheck disable=SC2155 +export NODE_TAG=$(buildkite-agent meta-data get node-tag) + +# shellcheck disable=SC2034 +export BUMP_CHANGES=xxx + +# shellcheck disable=SC2034 +export DOCKER_SHA=xxx + +# shellcheck disable=SC2016 +envsubst \ + < "$RELEASE_SCRIPTS_DIR/release-template.md" \ + > "$RELEASE_SCRIPTS_DIR/release-template-final.md" + +if [ "$RELEASE" == "false" ]; then + gh release delete nightly --yes || true +fi + +gh release create \ + -d \ + -F "$RELEASE_SCRIPTS_DIR/release-template-final.md" \ + -t "$title" \ + "$TAG" diff --git a/scripts/buildkite/release/push-tag.sh b/scripts/buildkite/release/push-tag.sh new file mode 100755 index 00000000000..73dac42a7f6 --- /dev/null +++ b/scripts/buildkite/release/push-tag.sh @@ -0,0 +1,26 @@ +#! /usr/bin/env bash + +set -euox pipefail + +RELEASE_GIT_COMMIT=$(buildkite-agent meta-data get release-candidate-commit) + +git tag -l | xargs git tag -d +git fetch --tags + +if [ "$RELEASE" == "false" ]; then + git tag -d nightly || true + TAG=nightly +else + TAG=$(buildkite-agent meta-data get release-version) + exists=$(git tag -l "$TAG") + if [ -n "$exists" ]; then + echo "Tag $TAG already exists. Remove it before proceeding." + exit 1 + fi +fi + +git tag -m "$TAG" "$TAG" "$RELEASE_GIT_COMMIT" + +git remote set-url origin "https://$GITHUB_TOKEN@github.com/cardano-foundation/cardano-wallet.git" + +git push origin -f "$TAG" diff --git a/scripts/buildkite/release/push-to-bump.sh b/scripts/buildkite/release/push-to-bump.sh index 48052f7ed04..41b0e425cb5 100755 --- a/scripts/buildkite/release/push-to-bump.sh +++ b/scripts/buildkite/release/push-to-bump.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash set -euox pipefail diff --git a/scripts/buildkite/release/release-candidate.sh b/scripts/buildkite/release/release-candidate.sh index 09f0e9cc13e..4efd53f8f22 100755 --- a/scripts/buildkite/release/release-candidate.sh +++ b/scripts/buildkite/release/release-candidate.sh @@ -14,7 +14,8 @@ tag_cabal_ver() { tag_date "$1" | sed -e s/-0/-/g -e s/-/./g } -git fetch --tags --force +git tag -l | xargs git tag -d +git fetch --tags BASE_COMMIT=$(git rev-parse HEAD) @@ -28,6 +29,8 @@ NEW_CABAL_VERSION=$(tag_cabal_ver "$NEW_GIT_TAG") OLD_GIT_TAG=$( git tag -l "v2*-*-*" | sort | tail -n1) +LAST_RELEASE_DATE=$(tag_date "$OLD_GIT_TAG") + OLD_CABAL_VERSION=$(tag_cabal_ver "$OLD_GIT_TAG") CARDANO_NODE_TAG=$(cardano-node version | head -n1 | awk '{print $2}') @@ -72,3 +75,6 @@ buildkite-agent meta-data set "release-candidate-commit" "$RELEASE_COMMIT" buildkite-agent meta-data set "release-candidate-branch" "$RELEASE_CANDIDATE_BRANCH" buildkite-agent meta-data set "release-cabal-version" "$NEW_CABAL_VERSION" buildkite-agent meta-data set "test-rc" "$TEST_RC" +buildkite-agent meta-data set "base-build" "$BUILDKITE_BUILD_ID" +buildkite-agent meta-data set "node-tag" "$CARDANO_NODE_TAG" +buildkite-agent meta-data set "last-release-date" "$LAST_RELEASE_DATE" diff --git a/scripts/buildkite/release/release-template.md b/scripts/buildkite/release/release-template.md new file mode 100644 index 00000000000..b61d324a2f1 --- /dev/null +++ b/scripts/buildkite/release/release-template.md @@ -0,0 +1,42 @@ +## Node Compatibility + +Compatible with [`cardano-node@$NODE_TAG`](https://github.com/input-output-hk/cardano-node/releases/tag/$NODE_TAG). + +## Docker Image + +FIX THIS LINK BY INSPECTING DOCKERHUB ! +[Image](https://hub.docker.com/layers/cardanofoundation/cardano-wallet/$CABAL-VERSION/images/$DOCKER_SHA) + +## Changes + +${CHANGES} + +### Fixed + +### Added + +### Changed + +### Removed + +## API changes + +FIX THIS LINK BY INSPECTING BUMP SH ! +[bump.hs](https://bump.sh/hal-cardano-foundation/doc/cardano-wallet-backend/changes/$BUMP_CHANGES_ID) + +## Known Issues + +* (ADP-2953) Revision of `cardano-node` is not reported within version in release bundle binary for Windows. +* (ADP-2635) Database connections do not seem to gracefully terminate on stopping the wallet. +* (ADP-2298) `Deposit_returned` is falsely reported on some incoming transactions (intermittently). +* (ADP-1831) `cardano-wallet` version from docker image does not report revision. + +## Signatures + +| Name | Role | Approval | +| ----------------------------------- | ----------------- | -------- | +| Heinrich Apfelmus @HeinrichApfelmus | Software Engineer | | +| Paolo Veronelli @paolino | Software Engineer | | +| Pawel Jakubas @paweljakubas | Software Engineer | | +| Johannes Lund @Anviking | Software Engineer | | +| David Clark @david-a-clark | Product Manager | | diff --git a/scripts/make_changelog.sh b/scripts/make_changelog.sh deleted file mode 100755 index d28033b1200..00000000000 --- a/scripts/make_changelog.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash - -# Constructs a CHANGELOG using every PR merged since a given date. It -# groups PRs by milestones. -# -# /!\ depends on 'jq' and 'curl' /!\ -# -# Usage: -# ./make_changelog.sh YYYY-MM-DD -# -# Example: -# ./make_changelog.sh 2019-08-15 - -# NOTE: You can optionally set $GITHUB_API_TOKEN before running this -# script to avoid GitHub rate limit errors. - -set -euo pipefail - -repo="cardano-foundation/cardano-wallet" -since_date="${1:-}" - -if [ -z "$since_date" ]; then - echo "usage: $0 YYYY-MM-DD" - exit 1 -fi - -fetch_prs() { - if [ -z "${GITHUB_API_TOKEN:-}" ]; then - echo "warning: GITHUB_API_TOKEN is not set. You may get a rate limit error when fetching pull requests." > /dev/stderr - auth_header=() - else - auth_header=("-H" "Authorization: token $GITHUB_API_TOKEN") - fi - - url="https://api.github.com/search/issues?per_page=500&q=repo:$1+is:pr+is:merged+merged:%3E$2" - echo "Fetching $url" > /dev/stderr - curl --silent "${auth_header[@]}" \ - -H "Accept: application/vnd.github.v3+json" \ - "$url" -} - -pull_requests=$(fetch_prs "$repo" "$since_date" | jq '.items | map({number:.number,title:.title,label:.labels[0].name}) | group_by(.label)') - -items=$(jq 'map(map("\(.title) #\(.number)"))' <<< "$pull_requests") -labels=$(jq 'map(map("\(.label)") | unique) | flatten' <<< "$pull_requests") - -labels_max=$(jq 'length - 1' <<< "$labels") - -for i in $(seq 0 "$labels_max"); do - label=$(jq -r ".[$i]" <<< "$labels") - case $label in - "null") - echo "## Unclassified (Move user-facing items to correct section. Delete the rest)" - ;; - "ADDING FEATURE") - echo "## New Features" - ;; - "IMPROVEMENT") - echo "## Improvements" - ;; - "RESOLVING ISSUE") - echo "## Resolved Issues" - ;; - esac - echo "" - jq -r '.['"$i"'] | .[] | "- \(.)"' <<< "$items" - echo "" -done