Skip to content

Commit

Permalink
Merge pull request #202 from HathorNetwork/release-candidate
Browse files Browse the repository at this point in the history
Release v1.6.3
  • Loading branch information
andreabadesso authored Dec 11, 2024
2 parents 5d20679 + 94e6871 commit 638c9e7
Show file tree
Hide file tree
Showing 42 changed files with 2,970 additions and 1,731 deletions.
307 changes: 216 additions & 91 deletions .codebuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,94 +9,219 @@ send_slack_message() {
-X POST https://slack.com/api/chat.postMessage;
}

echo "Building git ref ${GIT_REF_TO_DEPLOY}..."

exit=false;

# Checks whether there is a file called "rollback_mainnet_production", which is used by our other CodeBuild to indicate that this is a mainnet-production rollback
if [ -f "rollback_mainnet_production" ]; then
# Gets all env vars with `mainnet_` prefix and re-exports them without the prefix
for var in "${!mainnet_@}"; do
export ${var#mainnet_}="${!var}"
done
make deploy-lambdas-mainnet;
send_slack_message "Rollback performed on mainnet-production to: ${GIT_REF_TO_DEPLOY}";
exit=true;
fi;

# Checks whether there is a file called "rollback_testnet_production", which is used by our other CodeBuild to indicate that this is a testnet-production rollback
if [ -f "rollback_testnet_production" ]; then
# Gets all env vars with `testnet_` prefix and re-exports them without the prefix
for var in "${!testnet_@}"; do
export ${var#testnet_}="${!var}"
done
make deploy-lambdas-testnet;
send_slack_message "Rollback performed on testnet-production to: ${GIT_REF_TO_DEPLOY}";
exit=true;
fi;

if [ "$exit" = true ]; then
echo "Rollbacks performed successfully. Exiting now.";
exit 0;
fi

if expr "${GIT_REF_TO_DEPLOY}" : "master" >/dev/null; then
# Gets all env vars with `dev_` prefix and re-exports them without the prefix
for var in "${!dev_@}"; do
export ${var#dev_}="${!var}"
done

make migrate;
make build-daemon;
make deploy-lambdas-dev-testnet;
# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
make push-daemon;

elif expr "${GIT_REF_TO_DEPLOY}" : "v[0-9]\+\.[0-9]\+\.[0-9]\+-rc\.[0-9]\+" >/dev/null; then
# Gets all env vars with `mainnet_staging_` prefix and re-exports them without the prefix
for var in "${!mainnet_staging_@}"; do
export ${var#mainnet_staging_}="${!var}"
done

echo $GIT_REF_TO_DEPLOY > /tmp/docker_image_tag
make migrate;
make build-daemon;
make deploy-lambdas-mainnet-staging;
make push-daemon;
send_slack_message "New version deployed to mainnet-staging: ${GIT_REF_TO_DEPLOY}"
elif expr "${GIT_REF_TO_DEPLOY}" : "v.*" >/dev/null; then
# Gets all env vars with `testnet_` prefix and re-exports them without the prefix
for var in "${!testnet_@}"; do
export ${var#testnet_}="${!var}"
done

echo $GIT_REF_TO_DEPLOY > /tmp/docker_image_tag
make migrate;
make build-daemon;
make deploy-lambdas-testnet;
make push-daemon;

# Unsets all the testnet env vars so we make sure they don't leak to the mainnet deploy below
for var in "${!testnet_@}"; do
unset ${var#testnet_}
done

# Gets all env vars with `mainnet_` prefix and re-exports them without the prefix
for var in "${!mainnet_@}"; do
export ${var#mainnet_}="${!var}"
done
make migrate;
make build-daemon;
make deploy-lambdas-mainnet;
make push-daemon;
send_slack_message "New version deployed to testnet-production and mainnet-production: ${GIT_REF_TO_DEPLOY}"
else
# Gets all env vars with `dev_` prefix and re-exports them without the prefix
for var in "${!dev_@}"; do
export ${var#dev_}="${!var}"
done
make migrate;
make build-daemon;
make deploy-lambdas-dev-testnet;
make push-daemon;
fi;
deploy_hathor_network_account() {
exit=false;

# Checks whether there is a file called "rollback_mainnet_production", which is used by our other CodeBuild to indicate that this is a mainnet-production rollback
if [ -f "rollback_mainnet_production" ]; then
# Gets all env vars with `mainnet_` prefix and re-exports them without the prefix
for var in "${!mainnet_@}"; do
export ${var#mainnet_}="${!var}"
done
make deploy-lambdas-mainnet;
send_slack_message "Rollback performed on mainnet-production to: ${GIT_REF_TO_DEPLOY}";
exit=true;
fi;

# Checks whether there is a file called "rollback_testnet_production", which is used by our other CodeBuild to indicate that this is a testnet-production rollback
if [ -f "rollback_testnet_production" ]; then
# Gets all env vars with `testnet_` prefix and re-exports them without the prefix
for var in "${!testnet_@}"; do
export ${var#testnet_}="${!var}"
done
make deploy-lambdas-testnet;
send_slack_message "Rollback performed on testnet-production to: ${GIT_REF_TO_DEPLOY}";
exit=true;
fi;

if [ "$exit" = true ]; then
echo "Rollbacks performed successfully. Exiting now.";
exit 0;
fi

if expr "${GIT_REF_TO_DEPLOY}" : "master" >/dev/null; then
# Gets all env vars with `dev_` prefix and re-exports them without the prefix
for var in "${!dev_@}"; do
export ${var#dev_}="${!var}"
done

make migrate;
make build-daemon;
make deploy-lambdas-dev-testnet;
# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
make push-daemon;

elif expr "${GIT_REF_TO_DEPLOY}" : "v[0-9]\+\.[0-9]\+\.[0-9]\+-rc\.[0-9]\+" >/dev/null; then
# Gets all env vars with `mainnet_staging_` prefix and re-exports them without the prefix
for var in "${!mainnet_staging_@}"; do
export ${var#mainnet_staging_}="${!var}"
done

echo $GIT_REF_TO_DEPLOY > /tmp/docker_image_tag
make migrate;
make build-daemon;
make deploy-lambdas-mainnet-staging;
# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
make push-daemon;
send_slack_message "New version deployed to mainnet-staging: ${GIT_REF_TO_DEPLOY}"
elif expr "${GIT_REF_TO_DEPLOY}" : "v.*" >/dev/null; then
echo $GIT_REF_TO_DEPLOY > /tmp/docker_image_tag
make build-daemon;

# --- Testnet ---
# Gets all env vars with `testnet_` prefix and re-exports them without the prefix
for var in "${!testnet_@}"; do
export ${var#testnet_}="${!var}"
done

make migrate;
make deploy-lambdas-testnet;

# Unsets all the testnet env vars so we make sure they don't leak to other deploys
for var in "${!testnet_@}"; do
unset ${var#testnet_}
done

# --- Mainnet ---
# Gets all env vars with `mainnet_` prefix and re-exports them without the prefix
for var in "${!mainnet_@}"; do
export ${var#mainnet_}="${!var}"
done
make migrate;
make deploy-lambdas-mainnet;

# Unsets all the mainnet env vars so we make sure they don't leak to other deploys
for var in "${!mainnet_@}"; do
unset ${var#mainnet_}
done

# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
make push-daemon;
send_slack_message "New version deployed to testnet-production and mainnet-production: ${GIT_REF_TO_DEPLOY}"
else
# Gets all env vars with `dev_` prefix and re-exports them without the prefix
for var in "${!dev_@}"; do
export ${var#dev_}="${!var}"
done
make migrate;
make build-daemon;
make deploy-lambdas-dev-testnet;
# The idea here is that if the lambdas deploy fail, the built image won't be pushed:
make push-daemon;
fi;
}

deploy_nano_testnet() {
# Deploys the releases and release-candidates to our nano-testnet environment

# We deploy only the Lambdas here, because the daemon used in nano-testnet is the same as
# the one built in the hathor-network account, since it runs there as well

echo "Building git ref ${GIT_REF_TO_DEPLOY}..."

# This will match both releases and release-candidates
if expr "${GIT_REF_TO_DEPLOY}" : "v.*" >/dev/null; then
make migrate;
make deploy-lambdas-nano-testnet;

send_slack_message "New version deployed to nano-testnet: ${GIT_REF_TO_DEPLOY}"
elif expr "${MANUAL_DEPLOY}" : "true" >/dev/null; then
make migrate;
make deploy-lambdas-nano-testnet;

send_slack_message "Branch manually deployed to nano-testnet: ${GIT_REF_TO_DEPLOY}"
elif expr "${ROLLBACK}" : "true" >/dev/null; then
make migrate;
make deploy-lambdas-nano-testnet;

send_slack_message "Rollback performed on nano-tesnet to: ${GIT_REF_TO_DEPLOY}";
else
echo "We don't deploy ${GIT_REF_TO_DEPLOY} to nano-testnet. Nothing to do.";
fi;
}

deploy_ekvilibro_mainnet() {
# Deploys the releases to our ekvilibro-mainnet environment

# We deploy only the Lambdas here, because the daemon used in ekvilibro-testnet is the same as
# the one built in the hathor-network account, since it runs there as well

echo "Building git ref ${GIT_REF_TO_DEPLOY}..."

# This will match release-candidates
if expr "${GIT_REF_TO_DEPLOY}" : "v[0-9]\+\.[0-9]\+\.[0-9]\+-rc\.[0-9]\+" >/dev/null; then
echo "We don't deploy ${GIT_REF_TO_DEPLOY} to ekvilibro-mainnet. Nothing to do.";
# This will match releases only (since release-candidates are already matched above)
elif expr "${GIT_REF_TO_DEPLOY}" : "v.*" >/dev/null; then
make migrate;
make deploy-lambdas-ekvilibro-mainnet;

send_slack_message "New version deployed to ekvilibro-mainnet: ${GIT_REF_TO_DEPLOY}"
elif expr "${MANUAL_DEPLOY}" : "true" >/dev/null; then
make migrate;
make deploy-lambdas-ekvilibro-mainnet;

send_slack_message "Branch manually deployed to ekvilibro-mainnet: ${GIT_REF_TO_DEPLOY}"
elif expr "${ROLLBACK}" : "true" >/dev/null; then
make migrate;
make deploy-lambdas-ekvilibro-mainnet;

send_slack_message "Rollback performed on ekvilibro-mainnet to: ${GIT_REF_TO_DEPLOY}";
else
echo "We don't deploy ${GIT_REF_TO_DEPLOY} to ekvilibro-mainnet. Nothing to do.";
fi;

}

deploy_ekvilibro_testnet() {
# Deploys the release-candidates and releases to our ekvilibro-testnet environment

# We deploy only the Lambdas here, because the daemon used in ekvilibro-testnet is the same as
# the one built in the hathor-network account, since it runs there as well

echo "Building git ref ${GIT_REF_TO_DEPLOY}..."

# This will match release-candidates or releases
if expr "${GIT_REF_TO_DEPLOY}" : "v.*" >/dev/null; then
make migrate;
make deploy-lambdas-ekvilibro-testnet;

send_slack_message "New version deployed to ekvilibro-testnet: ${GIT_REF_TO_DEPLOY}"
elif expr "${MANUAL_DEPLOY}" : "true" >/dev/null; then
make migrate;
make deploy-lambdas-ekvilibro-testnet;

send_slack_message "Branch manually deployed to ekvilibro-testnet: ${GIT_REF_TO_DEPLOY}"
elif expr "${ROLLBACK}" : "true" >/dev/null; then
make migrate;
make deploy-lambdas-ekvilibro-testnet;

send_slack_message "Rollback performed on ekvilibro-testnet to: ${GIT_REF_TO_DEPLOY}";
else
echo "We don't deploy ${GIT_REF_TO_DEPLOY} to ekvilibro-testnet. Nothing to do.";
fi;
}


# Check the first argument for the desired deploy
option=$1

case $option in
# This will be triggered from /.codebuild/buildspec.yml in this repo
hathor-network)
deploy_hathor_network_account
;;
nano-testnet)
deploy_nano_testnet
;;
ekvilibro-testnet)
deploy_ekvilibro_testnet
;;
ekvilibro-mainnet)
deploy_ekvilibro_mainnet
;;
*)
echo "Invalid option: $option"
exit 1
;;
esac
6 changes: 5 additions & 1 deletion .codebuild/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ env:
dev_FIREBASE_CLIENT_X509_CERT_URL: "WalletService/dev:FIREBASE_CLIENT_X509_CERT_URL"
dev_ALERT_MANAGER_REGION: "WalletService/dev:ALERT_MANAGER_REGION"
dev_ALERT_MANAGER_TOPIC: "WalletService/dev:ALERT_MANAGER_TOPIC"
dev_ALERT_MANAGER_ACCOUNT_ID: "WalletService/dev:ALERT_MANAGER_ACCOUNT_ID"
# Testnet secrets
testnet_ACCOUNT_ID: "WalletService/testnet:account_id"
testnet_AUTH_SECRET: "WalletService/testnet:auth_secret"
Expand All @@ -114,6 +115,7 @@ env:
testnet_FIREBASE_CLIENT_X509_CERT_URL: "WalletService/testnet:FIREBASE_CLIENT_X509_CERT_URL"
testnet_ALERT_MANAGER_REGION: "WalletService/testnet:ALERT_MANAGER_REGION"
testnet_ALERT_MANAGER_TOPIC: "WalletService/testnet:ALERT_MANAGER_TOPIC"
testnet_ALERT_MANAGER_ACCOUNT_ID: "WalletService/testnet:ALERT_MANAGER_ACCOUNT_ID"
# Mainnet Staging secrets
mainnet_staging_ACCOUNT_ID: "WalletService/mainnet_staging:account_id"
mainnet_staging_AUTH_SECRET: "WalletService/mainnet_staging:auth_secret"
Expand All @@ -139,6 +141,7 @@ env:
mainnet_staging_FIREBASE_CLIENT_X509_CERT_URL: "WalletService/mainnet_staging:FIREBASE_CLIENT_X509_CERT_URL"
mainnet_staging_ALERT_MANAGER_REGION: "WalletService/mainnet_staging:ALERT_MANAGER_REGION"
mainnet_staging_ALERT_MANAGER_TOPIC: "WalletService/mainnet_staging:ALERT_MANAGER_TOPIC"
mainnet_staging_ALERT_MANAGER_ACCOUNT_ID: "WalletService/mainnet_staging:ALERT_MANAGER_ACCOUNT_ID"
# Mainnet secrets
mainnet_ACCOUNT_ID: "WalletService/mainnet:account_id"
mainnet_AUTH_SECRET: "WalletService/mainnet:auth_secret"
Expand All @@ -164,6 +167,7 @@ env:
mainnet_FIREBASE_CLIENT_X509_CERT_URL: "WalletService/mainnet:FIREBASE_CLIENT_X509_CERT_URL"
mainnet_ALERT_MANAGER_REGION: "WalletService/mainnet:ALERT_MANAGER_REGION"
mainnet_ALERT_MANAGER_TOPIC: "WalletService/mainnet:ALERT_MANAGER_TOPIC"
mainnet_ALERT_MANAGER_ACCOUNT_ID: "WalletService/mainnet:ALERT_MANAGER_ACCOUNT_ID"
phases:
install:
#If you use the Ubuntu standard image 2.0 or later, you must specify runtime-versions.
Expand All @@ -182,4 +186,4 @@ phases:
- export GIT_REF_TO_DEPLOY=$(cat git_ref_to_deploy)
build:
commands:
- bash .codebuild/build.sh
- bash .codebuild/build.sh hathor-network
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ build-daemon:
push-daemon:
bash scripts/push-daemon.sh

.PHONY: deploy-lambdas-nano-testnet
deploy-lambdas-nano-testnet:
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage nano --region eu-central-1 --aws-profile nano-testnet

.PHONY: deploy-lambdas-ekvilibro-testnet
deploy-lambdas-ekvilibro-testnet:
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage ekvilibro --region eu-central-1 --aws-profile ekvilibro

.PHONY: deploy-lambdas-ekvilibro-mainnet
deploy-lambdas-ekvilibro-mainnet:
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage ekvi-main --region eu-central-1 --aws-profile ekvilibro

.PHONY: deploy-lambdas-dev-testnet
deploy-lambdas-dev-testnet:
AWS_SDK_LOAD_CONFIG=1 yarn workspace wallet-service run serverless deploy --stage dev-testnet --region eu-central-1
Expand Down
18 changes: 18 additions & 0 deletions db/migrations/20241203185227-add-address-wallet_id-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
await queryInterface.addIndex(
'address',
['wallet_id', 'index'],
{
name: 'idx_wallet_address_index',
}
);
},

async down(queryInterface) {
await queryInterface.removeIndex('address', 'idx_wallet_address_index');
}
};
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
nixpkgs-fmt
nodejs_20
yarn
docker-compose
];
};
});
Expand Down
Loading

0 comments on commit 638c9e7

Please sign in to comment.