Skip to content

Commit fd6c64a

Browse files
authored
chore(scripts): add base release initializer (#11143)
closes: #11142 ## Description Adds an `init-release.sh` script to automate the mundane, repetitive parts of release initialization. Note that this only makes the necessary changes and other need-based changes go case-by-case (and manually) (for example, release with variants). Currently, it does the following tasks: - updates handler name in `app.go` - updates handler name, upgrade names in `upgrade.go` - renames `n:upgrade-next` to `a:upgrade-<release-number>` - updates the README in `a:upgrade-<release-number>` In the future, I will keep automating other bits and pieces of release process. However, next on my docket is to update this script to incorporate variants (at least until we get rid of them altogether). ### Security Considerations None ### Scaling Considerations None ### Documentation Considerations ~~Will add to MAINTAINERS.md in a follow up.~~ Updated MAINTAINERS.md ### Testing Considerations None for the sdk codebase. But for PR verification, can run it locally on master using `./init-release.sh 19` and it will do the needful. ### Upgrade Considerations None, this is a helper script for release process.
2 parents c101e37 + 5b8abba commit fd6c64a

File tree

2 files changed

+96
-13
lines changed

2 files changed

+96
-13
lines changed

MAINTAINERS.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ The Release Owner and other appropriate stakeholders must agree on:
2929

3030
- _**base branch**_: This should be `master`, but might need to vary for a patch release.
3131

32+
- _**release number**_: The number associated with the current release (example: `8` for `agoric-upgrade-8`).
33+
3234
- _**release label**_: This is used for the git tags, and is currently expected to follow a
33-
sequential pattern (example: `agoric-upgrade-8`).
35+
sequential pattern. It ends with the _**release number**_. (example: `agoric-upgrade-8`).
3436
The mainnet release label is preceded by release candidates numbered from zero
3537
(example: `agoric-upgrade-8-rc0`), and shares its commit with the final release candidate.
3638

@@ -46,18 +48,19 @@ The Release Owner and other appropriate stakeholders must agree on:
4648

4749
- [ ] When a new release is planned, create a new branch from the [_**base branch**_](#assign-release-parameters) (`master`) with a name like `dev-$releaseShortLabel` (example: `dev-upgrade-8`). This can be done from the command line or the [GitHub Branches UI](https://github.com/Agoric/agoric-sdk/branches).
4850
- [ ] Initialize the new branch for the planned upgrade:
49-
- [ ] In **golang/cosmos/app/upgrade.go**
50-
- [ ] Update the `upgradeNamesOfThisVersion` constant to list all the [_**upgrade name**_](#assign-release-parameters) used by this release.
51-
- [ ] Update the `isPrimaryUpgradeName` function to reflect the updated [_**upgrade name**_](#assign-release-parameters) list.
52-
- [ ] Rename the upgrade handler function to match the release, example: `upgrade8Handler`.
53-
- [ ] Verify that the upgrade handler function has no logic specific to the previous upgrade (e.g., core proposals).
54-
- [ ] In **golang/cosmos/app/app.go**, make sure that the call to `SetUpgradeHandler` uses the renamed upgrade handler function above.
55-
- [ ] Verify that **a3p-integration/package.json** has an object-valued `agoricSyntheticChain` property with `fromTag` set to the [agoric-3-proposals Docker images](https://github.com/Agoric/agoric-3-proposals/pkgs/container/agoric-3-proposals) tag associated with the previous release
56-
(example: `use-upgrade-7`) or latest core-eval passed on chain (example: `use-vaults-auction`).
57-
- [ ] Ensure that the first subdirectory in **a3p-integration/proposals** has the following characteristics. This is commonly created by renaming the `n:upgrade-next` directory after verifying no other proposals exist before that, and updating the **package.json** file in it.
58-
- named like "$prefix:[_**release short label**_](#assign-release-parameters)" per [agoric-3-proposals: Naming](https://github.com/Agoric/agoric-3-proposals#naming) (conventionally using "a" for the unreleased $prefix, e.g. `a:upgrade-8`).
59-
- containing a **package.json** having an object-valued `agoricProposal` property with `sdkImageTag` set to "unreleased" and `planName` set to the [_**upgrade name**_](#assign-release-parameters)
60-
- containing other files appropriate for the upgrade per [agoric-3-proposals: Files](https://github.com/Agoric/agoric-3-proposals#files)
51+
- [ ] Run **`scripts/init-release.sh $releaseNumber`** to make base changes for the new release. Verify and make need-based changes accordingly.
52+
- [ ] In **golang/cosmos/app/upgrade.go**
53+
- [ ] Update/verify the `upgradeNamesOfThisVersion` constant to list all the [_**upgrade name**_](#assign-release-parameters) used by this release.
54+
- [ ] Update/verify the `isPrimaryUpgradeName` function to reflect the updated [_**upgrade name**_](#assign-release-parameters) list.
55+
- [ ] Rename/verify the upgrade handler function to match the release, example: `upgrade8Handler`.
56+
- [ ] Verify that the upgrade handler function has no logic specific to the previous upgrade (e.g., core proposals).
57+
- [ ] In **golang/cosmos/app/app.go**, make sure that the call to `SetUpgradeHandler` uses the renamed upgrade handler function above.
58+
- [ ] Verify that **a3p-integration/package.json** has an object-valued `agoricSyntheticChain` property with `fromTag` set to the [agoric-3-proposals Docker images](https://github.com/Agoric/agoric-3-proposals/pkgs/container/agoric-3-proposals) tag associated with the previous release
59+
(example: `use-upgrade-7`) or latest core-eval passed on chain (example: `use-vaults-auction`).
60+
- [ ] Ensure that the first subdirectory in **a3p-integration/proposals** has the following characteristics. This is commonly created by renaming the `n:upgrade-next` directory after verifying no other proposals exist before that, and updating the **package.json** file in it. The `init-release.sh` script takes care of renaming the directory so verify the new proposal directory.
61+
- named like "$prefix:[_**release short label**_](#assign-release-parameters)" per [agoric-3-proposals: Naming](https://github.com/Agoric/agoric-3-proposals#naming) (conventionally using "a" for the unreleased $prefix, e.g. `a:upgrade-8`).
62+
- containing a **package.json** having an object-valued `agoricProposal` property with `sdkImageTag` set to "unreleased" and `planName` set to the [_**upgrade name**_](#assign-release-parameters)
63+
- containing other files appropriate for the upgrade per [agoric-3-proposals: Files](https://github.com/Agoric/agoric-3-proposals#files)
6164

6265
For example, see the [upgrade-17 PR](https://github.com/Agoric/agoric-sdk/pull/10088).
6366

scripts/init-release.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
set -ueo pipefail
3+
4+
if [ "$#" -ne 1 ]; then
5+
echo "Usage: $0 <next_release_number>"
6+
echo "Example: $0 19" # for agoric-upgrade-19
7+
exit 1
8+
fi
9+
10+
# for better compatibility
11+
BSD_SED="$(sed --help 2>&1 | sed 2q | grep -qe '-i ' && echo 1 || true)"
12+
function sedi() {
13+
if [ -n "$BSD_SED" ]; then
14+
sed -i '' "$@"
15+
else
16+
sed -i "$@"
17+
fi
18+
}
19+
20+
NEXT_RELEASE=$1
21+
if ! [[ "$NEXT_RELEASE" =~ ^[1-9][0-9]*$ ]]; then
22+
echo "Error: Release number must be a positive decimal integer"
23+
exit 1
24+
fi
25+
26+
APP_FILE=golang/cosmos/app/app.go
27+
UPGRADE_FILE=golang/cosmos/app/upgrade.go
28+
29+
# Rename unreleasedUpgradeHandler instances
30+
sedi -e "s/unreleasedUpgradeHandler/upgrade${NEXT_RELEASE}Handler/g" \
31+
-e "s/the unreleased upgrade/upgrade-${NEXT_RELEASE}/g" \
32+
${APP_FILE} \
33+
${UPGRADE_FILE}
34+
35+
echo "Renamed unreleasedUpgradeHandler for release u${NEXT_RELEASE}"
36+
37+
# Rename cosmos-sdk upgrade names
38+
sedi '/^var upgradeNamesOfThisVersion = \[\]string{/,/^}/ c\var upgradeNamesOfThisVersion = []string{\
39+
"agoric-upgrade-'"${NEXT_RELEASE}"'",\
40+
}' ${UPGRADE_FILE}
41+
echo "Updated cosmos-sdk upgrade names"
42+
43+
# Rename primary upgrade names
44+
sedi '/^func isPrimaryUpgradeName(name string) bool {/,/^}/ c\func isPrimaryUpgradeName(name string) bool {\
45+
if name == "" {\
46+
// An empty upgrade name can happen if there are no upgrade in progress\
47+
return false\
48+
}\
49+
switch name {\
50+
case validUpgradeName("agoric-upgrade-'"${NEXT_RELEASE}"'"):\
51+
return true\
52+
default:\
53+
panic(fmt.Errorf("unexpected upgrade name %s", validUpgradeName(name)))\
54+
}\
55+
}' ${UPGRADE_FILE}
56+
echo "Updated primary upgrade names"
57+
58+
# when done, format the files
59+
go fmt ${APP_FILE} ${UPGRADE_FILE}
60+
61+
# Rename upgrade-next to a:upgrade-${NEXT_RELEASE}
62+
if [ -d "a3p-integration/proposals/n:upgrade-next" ]; then
63+
mv "a3p-integration/proposals/n:upgrade-next" "a3p-integration/proposals/a:upgrade-${NEXT_RELEASE}"
64+
echo "Renamed n:upgrade-next directory to a:upgrade-${NEXT_RELEASE}"
65+
66+
cat > "a3p-integration/proposals/a:upgrade-${NEXT_RELEASE}/README.md" << EOF
67+
# Proposal to upgrade the chain software
68+
69+
This holds the draft proposal for agoric-upgrade-${NEXT_RELEASE}, which will be added to
70+
[agoric-3-proposals](https://github.com/Agoric/agoric-3-proposals) after it
71+
passes.
72+
73+
The "binaries" property of \`upgradeInfo\` is now required since Cosmos SDK 0.46,
74+
however it cannot be computed for an unreleased upgrade. To disable the check,
75+
\`releaseNotes\` is set to \`false\`.
76+
EOF
77+
echo "Updated README.md for a:upgrade-${NEXT_RELEASE}"
78+
else
79+
echo "Warning: n:upgrade-next directory not found. Skipping directory rename and README update."
80+
fi

0 commit comments

Comments
 (0)