Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release-scripts to protocol repo #4487

Merged
merged 11 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ jobs:
--storage-location=us
- slack-fail:
branch_pattern: main
slack_mentions_user: "@dheeraj"
slack_mentions_user: "@ray"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THANKS


publish-sdk:
docker:
Expand Down Expand Up @@ -1273,6 +1273,7 @@ jobs:
type: string
default: ""
steps:
- checkout
- add_ssh_keys:
fingerprints:
# github.com
Expand All @@ -1282,13 +1283,11 @@ jobs:
docker_layer_caching: true
- run: |
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
git clone git@github.com:AudiusProject/audius-tooling.git
cd audius-tooling
mkdir -p ssh_keys
cp ~/.ssh/id_rsa_d00ba019ac4658e46cac3499f61b31bb ssh_keys/
SLASH_ADDRESS=<< parameters.slash_address >> \
SLASH_AMOUNT=<< parameters.slash_amount >> \
release-scripts/<< parameters.target >>.sh
.circleci/release-scripts/<< parameters.target >>.sh
- slack-fail
- when:
condition:
Expand Down
6 changes: 6 additions & 0 deletions .circleci/release-scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Release to Production

* [Deployment Design Doc](https://www.notion.so/Deployment-Design-Doc-67f4fb5fb7574320a45dd63082ec4adf)
* [Deployment User Guide](https://www.notion.so/audiusproject/Deployment-User-Guide-708a8f64881740219d3f77707e73a097)

Called via audius-protocol's CircleCI project.
15 changes: 15 additions & 0 deletions .circleci/release-scripts/bump-hotfix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

script=bump-hotfix
docker build \
-t ${script} \
release-scripts/dockerfiles/${script}

SSH_KEY=$(cat ssh_keys/id_rsa_d00ba019ac4658e46cac3499f61b31bb)
docker run \
-ti \
-e SSH_KEY="${SSH_KEY}" \
-e GH_TOKEN="${GH_TOKEN}" \
${script}
15 changes: 15 additions & 0 deletions .circleci/release-scripts/cut-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

script=cut-release
docker build \
-t ${script} \
release-scripts/dockerfiles/${script}

SSH_KEY=$(cat ssh_keys/id_rsa_d00ba019ac4658e46cac3499f61b31bb)
docker run \
-ti \
-e SSH_KEY="${SSH_KEY}" \
-e GH_TOKEN="${GH_TOKEN}" \
${script}
3 changes: 3 additions & 0 deletions .circleci/release-scripts/dheeraj-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo "test from circleci"
pwd
ls
35 changes: 35 additions & 0 deletions .circleci/release-scripts/dockerfiles/bump-hotfix/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:22.04

ENV WORKDIR /app
WORKDIR ${WORKDIR}

RUN apt-get update \
&& apt-get install -y \
git \
gnupg \
jq \
moreutils \
wget \
&& sh -c "echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' \
>> /etc/apt/sources.list" \
&& wget -q 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' -O /tmp/gitsecret.key \
&& md5sum /tmp/gitsecret.key | grep -q "e941935ec5dd72a60086e1b5112ade3d" \
|| exit \
&& apt-key add /tmp/gitsecret.key \
&& apt-get update \
&& apt-get install -y \
git-secret

WORKDIR /tmp
RUN wget https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz \
&& md5sum ghr_v0.15.0_linux_amd64.tar.gz | grep -q "b820693296a40bddb3873284f6051b87" \
|| exit \
&& tar xf ghr_v0.15.0_linux_amd64.tar.gz \
&& mv ghr_v0.15.0_linux_amd64/ghr ${WORKDIR}/
WORKDIR ${WORKDIR}

RUN git clone https://github.com/AudiusProject/audius-protocol.git

COPY bump.sh ./

CMD ./bump.sh
63 changes: 63 additions & 0 deletions .circleci/release-scripts/dockerfiles/bump-hotfix/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

set -ex

# required for ./ghr to create and tag Github Releases
if [ "${GH_TOKEN}" == "" ]; then
echo '$GH_TOKEN not set.'
exit 1
fi

# ensure ability to connect to Github
eval $(ssh-agent)
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
ssh-add ~/.ssh/id_*
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh -T git@github.com || true
git config --global user.email "audius-infra@audius.co"
git config --global user.name "audius-infra"
git config --global url."git@github.com:".insteadOf "https://github.com/"

# work in and always update the repo
cd ${WORKDIR}/audius-protocol
git pull

# grab latest release version and hash
RELEASE_VERSION=$(jq -r .version ${WORKDIR}/audius-protocol/discovery-provider/.version.json)
OLD_VERSION=$(echo ${RELEASE_VERSION} | awk -F. '{$NF = $NF - 1;} 1' | sed 's/ /./g')
git checkout release-v${RELEASE_VERSION}
RELEASE_HASH=$(git rev-parse HEAD)

function generate-changelog() {
(
SERVICE=${1}
START_COMMIT=$(git show-ref --hash refs/tags/@audius/${SERVICE}@${OLD_VERSION})
CHANGE_LOG=$(git log --pretty=format:'[%h] - %s' --abbrev-commit ${START_COMMIT}..${RELEASE_HASH} ${SERVICE})
echo -e "Full Changelog:\n${CHANGE_LOG}"
)
}

# recreate Github Releases (prerelease) + Git Tags
${WORKDIR}/ghr \
-token ${GH_TOKEN} \
-username AudiusProject \
-repository audius-protocol \
-commitish ${RELEASE_HASH} \
-body "$(generate-changelog discovery-provider)" \
-name "Discovery Provider ${RELEASE_VERSION}" \
-delete \
-prerelease \
@audius/discovery-provider@${RELEASE_VERSION}

${WORKDIR}/ghr \
-token ${GH_TOKEN} \
-username AudiusProject \
-repository audius-protocol \
-commitish ${RELEASE_HASH} \
-body "$(generate-changelog creator-node)" \
-name "Creator Node ${RELEASE_VERSION}" \
-delete \
-prerelease \
@audius/creator-node@${RELEASE_VERSION}
35 changes: 35 additions & 0 deletions .circleci/release-scripts/dockerfiles/cut-release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:22.04

ENV WORKDIR /app
WORKDIR ${WORKDIR}

RUN apt-get update \
&& apt-get install -y \
git \
gnupg \
jq \
moreutils \
wget \
&& sh -c "echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' \
>> /etc/apt/sources.list" \
&& wget -q 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' -O /tmp/gitsecret.key \
&& md5sum /tmp/gitsecret.key | grep -q "e941935ec5dd72a60086e1b5112ade3d" \
|| exit \
&& apt-key add /tmp/gitsecret.key \
&& apt-get update \
&& apt-get install -y \
git-secret

WORKDIR /tmp
RUN wget https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz \
&& md5sum ghr_v0.15.0_linux_amd64.tar.gz | grep -q "b820693296a40bddb3873284f6051b87" \
|| exit \
&& tar xf ghr_v0.15.0_linux_amd64.tar.gz \
&& mv ghr_v0.15.0_linux_amd64/ghr ${WORKDIR}/
WORKDIR ${WORKDIR}

RUN git clone https://github.com/AudiusProject/audius-protocol.git

COPY cut.sh ./

CMD ./cut.sh
75 changes: 75 additions & 0 deletions .circleci/release-scripts/dockerfiles/cut-release/cut.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash

set -ex

# required for ./ghr to create and tag Github Releases
if [ "${GH_TOKEN}" == "" ]; then
echo '$GH_TOKEN not set.'
exit 1
fi

# ensure ability to connect to Github
eval $(ssh-agent)
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
ssh-add ~/.ssh/id_*
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh -T git@github.com || true
git config --global user.email "audius-infra@audius.co"
git config --global user.name "audius-infra"
git config --global url."git@github.com:".insteadOf "https://github.com/"

# work in and always update the repo
cd ${WORKDIR}/audius-protocol
git pull

# grab latest release version and generate new release version
OLD_VERSION=$(jq -r .version ${WORKDIR}/audius-protocol/discovery-provider/.version.json)
RELEASE_VERSION=$(echo ${OLD_VERSION} | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')

# update .version.json to new version
JSON=${WORKDIR}/audius-protocol/discovery-provider/.version.json
jq ".version=\"${RELEASE_VERSION}\"" ${JSON} | sponge ${JSON}
JSON=${WORKDIR}/audius-protocol/creator-node/.version.json
jq ".version=\"${RELEASE_VERSION}\"" ${JSON} | sponge ${JSON}

# commit version bump and create release branch
git add */.version.json
git commit -m "Bump to version ${RELEASE_VERSION}"
RELEASE_HASH=$(git rev-parse HEAD)
git checkout -b release-v${RELEASE_VERSION}
git push origin main
git push origin release-v${RELEASE_VERSION}

function generate-changelog() {
(
SERVICE=${1}
START_COMMIT=$(git show-ref --hash refs/tags/@audius/${SERVICE}@${OLD_VERSION})
CHANGE_LOG=$(git log --pretty=format:'[%h] - %s' --abbrev-commit ${START_COMMIT}..${RELEASE_HASH} ${SERVICE})
echo -e "Full Changelog:\n${CHANGE_LOG}"
)
}

# create Github Releases (prerelease) + Git Tags
${WORKDIR}/ghr \
-token ${GH_TOKEN} \
-username AudiusProject \
-repository audius-protocol \
-commitish ${RELEASE_HASH} \
-body "$(generate-changelog discovery-provider)" \
-name "Discovery Provider ${RELEASE_VERSION}" \
-soft \
-prerelease \
@audius/discovery-provider@${RELEASE_VERSION}

${WORKDIR}/ghr \
-token ${GH_TOKEN} \
-username AudiusProject \
-repository audius-protocol \
-commitish ${RELEASE_HASH} \
-body "$(generate-changelog creator-node)" \
-name "Creator Node ${RELEASE_VERSION}" \
-soft \
-prerelease \
@audius/creator-node@${RELEASE_VERSION}
39 changes: 39 additions & 0 deletions .circleci/release-scripts/dockerfiles/evaluate-proposal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM node:16

ENV WORKDIR /app
WORKDIR ${WORKDIR}

RUN apt-get update \
&& apt-get install -y \
git \
gnupg \
jq \
moreutils \
wget \
&& sh -c "echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' \
>> /etc/apt/sources.list" \
&& wget -q 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' -O /tmp/gitsecret.key \
&& md5sum /tmp/gitsecret.key | grep -q "e941935ec5dd72a60086e1b5112ade3d" \
|| exit \
&& apt-key add /tmp/gitsecret.key \
&& apt-get update \
&& apt-get install -y \
git-secret

WORKDIR /tmp
RUN wget https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz \
&& md5sum ghr_v0.15.0_linux_amd64.tar.gz | grep -q "b820693296a40bddb3873284f6051b87" \
|| exit \
&& tar xf ghr_v0.15.0_linux_amd64.tar.gz \
&& mv ghr_v0.15.0_linux_amd64/ghr ${WORKDIR}/
WORKDIR ${WORKDIR}

RUN git clone https://github.com/AudiusProject/audius-protocol.git \
&& git clone https://github.com/AudiusProject/audius-docker-compose.git

COPY package.json ./
RUN npm install

COPY evaluate.js ./

CMD npm run main
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { libs } = require('@audius/sdk')
const HDWalletProvider = require('@truffle/hdwallet-provider')
const Web3 = require('web3')

const localKeyProvider = new HDWalletProvider({
privateKeys: [process.env.OWNER_PRIVATE_KEY],
providerOrUrl: process.env.ETH_PROVIDER_ENDPOINT,
})
const providers = [new Web3(localKeyProvider)]

const audiusLibs = new libs({
ethWeb3Config: libs.configEthWeb3(
process.env.ETH_TOKEN_ADDRESS,
process.env.ETH_REGISTRY_ADDRESS,
providers,
process.env.OWNER_WALLET
),
isServer: true,
enableUserReplicaSetManagerContract: true
})

const main = async () => {
await audiusLibs.init()
const web3 = audiusLibs.ethWeb3Manager.getWeb3()

const inProgressIds = await audiusLibs.ethContracts.GovernanceClient.getInProgressProposals()
console.log(`Found ${inProgressIds.length} in progress proposals: ${inProgressIds}`)

for (const proposalId of inProgressIds) {
console.log(`Evaluating proposal: ${proposalId}`)

try {
const txReceipt = await audiusLibs.ethContracts.GovernanceClient.evaluateProposalOutcome(
proposalId
)

console.log(txReceipt)
console.log(JSON.stringify(txReceipt))

// TODO: Determine if proposal was evaluated as expected
// if (txReceipt.logs[0].event == 'ProposalOutcomeEvaluated') {
// console.log(`ProposalOutcomeEvaluated: ${proposalId}`)
// } else {
// console.error(`Proposal ${proposalId} outcome: ${txReceipt}.`)
// }
} catch (e) {
console.error(`Error evaluating proposal: ${proposalId}`)
console.error(e.stack)
}
}
console.log('done.')
process.exit(0)
}

main()
Loading