|
| 1 | +name: Release - chainweb-node - binary release scripts |
| 2 | + |
| 3 | +## Release automation for chainweb-node |
| 4 | +# Designed to run systems in chainweb/binary-release |
| 5 | + |
| 6 | +## Currently has manual version setting and creates draft releases; |
| 7 | +# when we are confident in this process, it can auto-increment and publish non-drafts |
| 8 | +# tbd: connect k8s firing mechanism, create and connect chainweb-node-docker update workflow |
| 9 | + |
| 10 | +run-name: "Release chainweb-node ${{ inputs.release_sha }} from ${{ github.sha}}" |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + release_sha: |
| 15 | + description: "hash of chainweb-node release, default to branch running this job" |
| 16 | + type: string |
| 17 | + required: false |
| 18 | + new_tag: |
| 19 | + description: "The X.Y.Z tag for the new version" |
| 20 | + type: string |
| 21 | + required: true |
| 22 | + old_tag: |
| 23 | + description: "The X.Y.Z of the old version" |
| 24 | + type: string |
| 25 | + required: true |
| 26 | +# tag_default_bump: |
| 27 | +# description: "Auto-bump release version id" |
| 28 | +# type: choice |
| 29 | +# options: |
| 30 | +# - patch |
| 31 | +# - minor |
| 32 | +# - major |
| 33 | +# - none |
| 34 | + dry_run: |
| 35 | + description: "dry run (debugging)" |
| 36 | + type: boolean |
| 37 | + default: false |
| 38 | + |
| 39 | +jobs: |
| 40 | + Finalize-release: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + # if this plugin is bad we just override it |
| 44 | +# - name: Bump version and push tag |
| 45 | +# id: tag_version |
| 46 | +# uses: mathieudutour/[email protected] |
| 47 | +# with: |
| 48 | +# github_token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | +# default_bump: ${{ inputs.tag_default_bump }} |
| 50 | +# tag_prefix: "" |
| 51 | +# commit_sha: ${{ inputs.release_sha }} |
| 52 | + # This is up here so we can adjust the way we handle package bumping etc |
| 53 | + # might not want to use the above plugin/don't want to depend on its outputs |
| 54 | + # yeah that thing is for rapid releasing tbh |
| 55 | + |
| 56 | + - name: Set environment variables for release |
| 57 | + run: | |
| 58 | + RELEASE_SHA=${{ github.sha }} |
| 59 | + if [[ ! -z ${{ inputs.release_sha }} ]]; then |
| 60 | + RELEASE_SHA=${{ inputs.release_sha }} |
| 61 | + fi |
| 62 | + echo "RELEASE_SHA=$RELEASE_SHA" >> $GITHUB_ENV |
| 63 | + SHORT_REVISION=$(echo $RELEASE_SHA | cut -c 1-7) |
| 64 | + echo "SHORT_REVISION=$SHORT_REVISION" >> $GITHUB_ENV |
| 65 | + #echo "VERSION_NEW=${{ steps.tag_version.outputs.new_tag }}" >> $GITHUB_ENV |
| 66 | + #echo "VERSION_OLD=${{ steps.tag_version.outputs.old_tag }}" >> $GITHUB_ENV |
| 67 | + echo "VERSION_NEW=${{ inputs.new_tag }}" >> $GITHUB_ENV |
| 68 | + echo "VERSION_OLD=${{ inputs.old_tag }}" >> $GITHUB_ENV |
| 69 | + echo "IMAGE=ghcr.io/kadena-io/chainweb-node:sha-$SHORT_REVISION" >> $GITHUB_ENV |
| 70 | + echo $GITHUB_ENV |
| 71 | +
|
| 72 | + - uses: actions/checkout@v3 |
| 73 | + with: |
| 74 | + repository: kadena-io/chainweb-node-docker |
| 75 | + path: dockerhub |
| 76 | + ssh-key: ${{ secrets.GH_DEPLOYKEY_CHAINWEBDOCKER }} |
| 77 | + |
| 78 | + #- name: derive release id from branch name? |
| 79 | + # if this was a release branch we'd do this to override the inputs |
| 80 | + # first run we are releasing from master (release branch kinda not needed if we just force release build logic during 'freeze') |
| 81 | + # The release actions out there sometimes will just do this increment for us |
| 82 | + - name: UBUNTU IMAGE bump end-user docker image |
| 83 | + working-directory: dockerhub |
| 84 | + continue-on-error: true |
| 85 | + run: | |
| 86 | + echo "DOCKERHUB_SHA=not yet updated" >> $GITHUB_ENV |
| 87 | + git clone https://github.com/kadena-io/chainweb-node-docker |
| 88 | + sed -i -e "s/ARG REVISION=.*/ARG REVISION=$SHORT_REVISION/" Dockerfile |
| 89 | + docker build -t kadena/chainweb-node:$VERSION_NEW . |
| 90 | + docker run --rm kadena/chainweb-node:$VERSION_NEW ./chainweb-node --version |
| 91 | +
|
| 92 | + git config --local user.name "github-actions[chainweb-node release]" |
| 93 | + git config --local user.email "[email protected]" |
| 94 | + git add Dockerfile |
| 95 | + git commit -m "chainweb-node version $VERSION_NEW" |
| 96 | + git tag chainweb-$VERSION_NEW |
| 97 | + git push |
| 98 | + git push origin chainweb-$VERSION_NEW |
| 99 | +
|
| 100 | + echo ${{ secrets.DOCKERHUB_PAT }} | docker login docker.io --username ${{ secrets.DOCKERHUB_USER }} --password-stdin |
| 101 | +
|
| 102 | + docker tag kadena/chainweb-node:$VERSION_NEW kadena/chainweb-node:latest |
| 103 | + docker image push --all-tags kadena/chainweb-node |
| 104 | + |
| 105 | + ## spit these to output |
| 106 | + digest1=$(docker inspect kadena/chainweb-node:$VERSION_NEW --format '{{ .RepoDigests }}') |
| 107 | + digest2=$(docker inspect kadena/chainweb-node:latest --format '{{ .RepoDigests }}') |
| 108 | + if [[ $digest1 != $digest2 ]]; then |
| 109 | + echo "DOCKERHUB_SHA=sha mismatches in dockerhub image" >> $GITHUB_ENV |
| 110 | + exit 1 |
| 111 | + fi |
| 112 | + echo "DOCKERHUB_SHA=$digest1" >> $GITHUB_ENV |
| 113 | + |
| 114 | + # all of this should really just be a BUMP IMAGE VERSION step in the other repo |
| 115 | + # Now in this workflow, trigger the above, spit output into release notes file |
| 116 | +
|
| 117 | + - uses: actions/checkout@v3 |
| 118 | + with: |
| 119 | + ref: ${{ env.RELEASE_SHA }} |
| 120 | + sparse-checkout: 'CHANGELOG.md' |
| 121 | + |
| 122 | + - name: tag git sha with release version |
| 123 | + run: | |
| 124 | + git tag ${{ env.VERSION_NEW }} ${{ env.RELEASE_SHA }} |
| 125 | + git push --tags |
| 126 | +
|
| 127 | + - name: Login to GHCR |
| 128 | + uses: docker/login-action@v2 |
| 129 | + with: |
| 130 | + registry: ghcr.io |
| 131 | + username: ${{ github.actor }} |
| 132 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + |
| 134 | + - name: retag ghcr docker images |
| 135 | + continue-on-error: true |
| 136 | + env: |
| 137 | + IMAGE: ${{ env.IMAGE }} |
| 138 | + SHORT_REVISION: ${{ env.SHORT_REVISION }} |
| 139 | + VERSION_NEW: ${{ env.VERSION_NEW }} |
| 140 | + run: | |
| 141 | + docker pull $IMAGE |
| 142 | + docker run --rm $IMAGE --version |
| 143 | + docker tag ghcr.io/kadena-io/chainweb-node:sha-$SHORT_REVISION ghcr.io/kadena-io/chainweb-node/ubuntu:$VERSION_NEW |
| 144 | + docker tag ghcr.io/kadena-io/chainweb-node:sha-$SHORT_REVISION ghcr.io/kadena-io/chainweb-node/ubuntu:latest |
| 145 | + docker tag ghcr.io/kadena-io/chainweb-node:sha-$SHORT_REVISION ghcr.io/kadena-io/chainweb-node:latest |
| 146 | + |
| 147 | + docker image ls |
| 148 | + |
| 149 | + docker image push --all-tags ghcr.io/kadena-io/chainweb-node/ubuntu |
| 150 | + docker image push --all-tags ghcr.io/kadena-io/chainweb-node |
| 151 | + |
| 152 | + digest1=$(docker inspect ghcr.io/kadena-io/chainweb-node:sha-$SHORT_REVISION --format '{{ .RepoDigests }}') |
| 153 | + digest2=$(docker inspect ghcr.io/kadena-io/chainweb-node/ubuntu:$VERSION_NEW --format '{{ .RepoDigests }}') |
| 154 | + digest3=$(docker inspect ghcr.io/kadena-io/chainweb-node/ubuntu:latest --format '{{ .RepoDigests }}') |
| 155 | + if [[ "$digest1" != "$digest2" || "$digest2" != "$digest3" ]]; then |
| 156 | + echo "GHCR_DIGEST=GHCR digests do not compare correctly" >> $GITHUB_ENV |
| 157 | + exit 1 |
| 158 | + fi |
| 159 | + echo "GHCR_DIGEST=$digest2" >> $GITHUB_ENV |
| 160 | +
|
| 161 | + - name: run release script to generate images |
| 162 | + id: repack-binaries |
| 163 | + env: |
| 164 | + SHORT_REVISION: ${{ env.SHORT_REVISION }} |
| 165 | + VERSION_NEW: ${{ env.VERSION_NEW }} |
| 166 | + run: | |
| 167 | + |
| 168 | + GHC_VER=9.6.2 |
| 169 | +
|
| 170 | + UBUNTU_20_TAR=chainweb.false.$GHC_VER.ubuntu-20.04.$SHORT_REVISION.tar.gz |
| 171 | + UBUNTU_22_TAR=chainweb.false.$GHC_VER.ubuntu-22.04.$SHORT_REVISION.tar.gz |
| 172 | + |
| 173 | + UBUNTU_20_NODE=chainweb-$VERSION_NEW.ghc-$GHC_VER.ubuntu-20.04.$SHORT_REVISION.tar.gz |
| 174 | + UBUNTU_22_NODE=chainweb-$VERSION_NEW.ghc-$GHC_VER.ubuntu-22.04.$SHORT_REVISION.tar.gz |
| 175 | + echo $UBUNTU_22_TAR |
| 176 | + echo $UBUNTU_22_NODE |
| 177 | + |
| 178 | + curl "s3.us-east-1.amazonaws.com/kadena-cabal-cache/chainweb-node/$UBUNTU_20_TAR" -o "./$UBUNTU_20_TAR" |
| 179 | + curl "s3.us-east-1.amazonaws.com/kadena-cabal-cache/chainweb-node/$UBUNTU_22_TAR" -o "./$UBUNTU_22_TAR" |
| 180 | + |
| 181 | + tar xvfz "$UBUNTU_20_TAR" chainweb/chainweb-node |
| 182 | + mv chainweb/chainweb-node . |
| 183 | + tar cvfz "$UBUNTU_20_NODE" chainweb-node |
| 184 | + rm -fr chainweb-node chainweb |
| 185 | + |
| 186 | + tar xvfz "$UBUNTU_22_TAR" chainweb/chainweb-node |
| 187 | + mv chainweb/chainweb-node . |
| 188 | + tar cvfz "$UBUNTU_22_NODE" chainweb-node |
| 189 | + rm -fr chainweb-node chainweb |
| 190 | + |
| 191 | + echo "UBUNTU_20_SHA=$(shasum -a 256 $UBUNTU_20_NODE)" >> $GITHUB_ENV |
| 192 | + echo "UBUNTU_22_SHA=$(shasum -a 256 $UBUNTU_22_NODE)" >> $GITHUB_ENV |
| 193 | + shasum -a 256 "$UBUNTU_22_NODE" |
| 194 | + echo "UBUNTU_20_NODE=$UBUNTU_20_NODE" >> $GITHUB_ENV |
| 195 | + echo "UBUNTU_22_NODE=$UBUNTU_22_NODE" >> $GITHUB_ENV |
| 196 | +
|
| 197 | + #- name: generate release message |
| 198 | + # could generate this from the changelog.md, though changelog.md could be itself generated... |
| 199 | + #oom_score_adj: |
| 200 | + |
| 201 | + - name: Generate release message |
| 202 | + continue-on-error: true |
| 203 | + env: |
| 204 | + UBUNTU_22_NODE: ${{ env.UBUNTU_22_NODE }} |
| 205 | + UBUNTU_20_NODE: ${{ env.UBUNTU_20_NODE }} |
| 206 | + IMAGE: ${{ env.IMAGE }} |
| 207 | + SHORT_REVISION: ${{ env.SHORT_REVISION }} |
| 208 | + VERSION_NEW: ${{ env.VERSION_NEW }} |
| 209 | + VERSION_OLD: ${{ env.VERSION_OLD }} |
| 210 | + GHCR_DIGEST: ${{ env.GHCR_DIGEST }} |
| 211 | + run: | |
| 212 | + pwd |
| 213 | + ls |
| 214 | + sed "/$VERSION_OLD\s/,\$d" CHANGELOG.md | sed "/$VERSION_NEW (20/d" | sed '/\sChangelog/d' | tee CHANGELOG.md |
| 215 | + echo 'Official release: https://github.com/kadena-io/chainweb-node/releases/tag/${{ env.VERSION_NEW }} |
| 216 | + |
| 217 | + For full details refer to the [Changelog](https://github.com/kadena-io/chainweb-node/blob/master/CHANGELOG.md) |
| 218 | + |
| 219 | + ### Container Images: |
| 220 | +
|
| 221 | + * [End-user image](https://hub.docker.com/r/kadena/chainweb-node) |
| 222 | + Image Digest: `${{ env.DOCKERHUB_SHA }}` |
| 223 | + ```sh |
| 224 | + docker pull kadena/chainweb-node:${{ env.VERSION_NEW }} |
| 225 | + ``` |
| 226 | + |
| 227 | + * [Binary-only Ubuntu-20.04 ](ghcr.io/kadena-io/chainweb-node/ubuntu:${{ env.VERSION_NEW }}) |
| 228 | + Image Digest: `${{ env.GHCR_DIGEST }}` |
| 229 | + ```sh |
| 230 | + docker pull ghcr.io/kadena-io/chainweb-node/ubuntu:${{ env.VERSION_NEW }} |
| 231 | + ``` |
| 232 | + |
| 233 | + ### Ubuntu Binaries: |
| 234 | + |
| 235 | + SHA256 Hashes |
| 236 | + |
| 237 | + ``` |
| 238 | + ${{ env.UBUNTU_22_SHA }} |
| 239 | + ${{ env.UBUNTU_20_SHA }} |
| 240 | + ``` |
| 241 | + |
| 242 | + The following dependencies must be installed on the system: |
| 243 | + |
| 244 | + * ubuntu-22.04: |
| 245 | + ```sh |
| 246 | + apt-get install ca-certificates libgmp10 libssl3 libsnappy1v5 zlib1g liblz4-1 libbz2-1.0 libgflags2.2 zstd |
| 247 | + ``` |
| 248 | + * ubuntu-20.04: |
| 249 | + ```sh |
| 250 | + apt-get install ca-certificates libgmp10 libssl1.1 libsnappy1v5 zlib1g liblz4-1 libbz2-1.0 libgflags2.2 zstd |
| 251 | + ``` |
| 252 | + ' >> CHANGELOG.md |
| 253 | + cat CHANGELOG.md |
| 254 | + |
| 255 | + - name: Release |
| 256 | + uses: ncipollo/release-action@v1 |
| 257 | + #if: startsWith(github.ref, 'refs/tags/') |
| 258 | + with: |
| 259 | + bodyFile: CHANGELOG.md |
| 260 | + artifacts: "${{ env.UBUNTU_20_NODE }},${{ env.UBUNTU_22_NODE }}" |
| 261 | + token: ${{ github.token }} |
| 262 | + tag: ${{ env.VERSION_NEW }} |
| 263 | + commit: ${{ env.RELEASE_SHA }} |
| 264 | + name: ${{ env.VERSION_NEW }} |
| 265 | + omitBodyDuringUpdate: true |
| 266 | + skipIfReleaseExists: true |
| 267 | + draft: true |
| 268 | + |
| 269 | + |
| 270 | + - name: Deploy to mainnet api.chainweb.com |
| 271 | + run: | |
| 272 | + echo "This will be a remote trigger" >> $GITHUB_STEP_SUMMARY |
0 commit comments