@@ -19,6 +19,7 @@ permissions:
1919env :
2020 NX_NO_CLOUD : true
2121 NX_SKIP_NX_CACHE : true
22+ DOCKER_HUB_USERNAME : " bgdeploybot"
2223
2324jobs :
2425 get-release-context :
3031 last-release-sha : ${{ steps.get-release-info.outputs.last-release-sha }}
3132 current-master-sha : ${{ steps.get-release-info.outputs.current-master-sha }}
3233 commits-since-release : ${{ steps.get-release-info.outputs.commits-since-release }}
34+ express-version : ${{ steps.compute-express-git-tag.outputs.version }}
35+ express-git-tag : ${{ steps.compute-express-git-tag.outputs.git-tag }}
36+ express-git-sha : ${{ steps.compute-express-git-sha.outputs.git-sha }}
3337 steps :
3438 - name : Checkout repository
3539 uses : actions/checkout@v6
@@ -108,6 +112,85 @@ jobs:
108112
109113 echo "" >> "$GITHUB_STEP_SUMMARY"
110114
115+ - name : Checkout rel/latest branch
116+ if : inputs.dry-run == false
117+ uses : actions/checkout@v6
118+ with :
119+ ref : rel/latest
120+
121+ - name : Compute express target version and tag
122+ if : inputs.dry-run == false
123+ id : compute-express-git-tag
124+ run : |
125+ VERSION=$(jq -r '.version' ./modules/express/package.json)
126+ TAG="@bitgo/express@$VERSION"
127+ echo "Current latest express version: $VERSION"
128+ echo "Expected latest express git tag: $TAG"
129+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
130+ echo "git-tag=$TAG" >> "$GITHUB_OUTPUT"
131+
132+ - name : Checkout express target git tag
133+ if : inputs.dry-run == false
134+ uses : actions/checkout@v6
135+ with :
136+ ref : ${{ steps.compute-express-git-tag.outputs.git-tag }}
137+ fetch-depth : 2
138+
139+ - name : Parse express release information
140+ if : inputs.dry-run == false
141+ id : compute-express-git-sha
142+ run : |
143+ GIT_SHA=$(git rev-parse HEAD)
144+ echo "Git SHA: $GIT_SHA"
145+ echo "git-sha=$GIT_SHA" >> "$GITHUB_OUTPUT"
146+
147+ - name : Sanity Check Express Git Tag
148+ if : inputs.dry-run == false
149+ run : |
150+ # Since git tags can be moved, we need to ensure the tag we're releasing
151+ # actually corresponds to a version bump in package.json
152+ CURRENT_VERSION="${{ steps.compute-express-git-tag.outputs.version }}"
153+ PREVIOUS_VERSION=$(git show HEAD~1:./modules/express/package.json | jq -r '.version')
154+
155+ echo "Current version: $CURRENT_VERSION"
156+ echo "Previous version: $PREVIOUS_VERSION"
157+
158+ if [ "$CURRENT_VERSION" == "$PREVIOUS_VERSION" ]; then
159+ echo "::error::Express version bump does not line up with git tag location."
160+ echo "::error::This suggests the git tag may have been moved."
161+ exit 1
162+ fi
163+
164+ echo "✅ Express version bump lines up with git tag"
165+
166+ - name : Check if Docker image already exists in Docker Hub
167+ if : inputs.dry-run == false
168+ run : |
169+ VERSION="${{ steps.compute-express-git-tag.outputs.version }}"
170+
171+ if curl -s -f "https://hub.docker.com/v2/repositories/bitgo/express/tags/$VERSION" > /dev/null; then
172+ echo "::error::Docker image bitgo/express:$VERSION already exists in Docker Hub"
173+ exit 1
174+ fi
175+
176+ echo "✅ Docker image bitgo/express:$VERSION does not exist in Docker Hub"
177+
178+ - name : Update Express GitHub summary
179+ if : inputs.dry-run == false
180+ run : |
181+ {
182+ echo "## BitGo Express Release Information"
183+ echo ""
184+ echo "Express Version: ${{ steps.compute-express-git-tag.outputs.version }}"
185+ echo "Git Tag: ${{ steps.compute-express-git-tag.outputs.git-tag }}"
186+ echo "Commit SHA: ${{ steps.compute-express-git-sha.outputs.git-sha }}"
187+ echo ""
188+ echo "### Docker Images to be deployed:"
189+ echo "- \`bitgo/express:latest\`"
190+ echo "- \`bitgo/express:${{ steps.compute-express-git-tag.outputs.version }}\`"
191+ echo ""
192+ } >> "$GITHUB_STEP_SUMMARY"
193+
111194 release-bitgojs :
112195 name : Release BitGoJS
113196 needs :
@@ -200,3 +283,48 @@ jobs:
200283 --latest \
201284 --title "v${{ steps.extract-version.outputs.new-version }}" \
202285 --notes-file "${{ steps.version-bump-summary.outputs.text-file }}"
286+
287+ publish-express-to-docker-hub :
288+ name : Publish Express To Docker Hub
289+ if : inputs.dry-run == false
290+ needs :
291+ - get-release-context
292+ - release-bitgojs
293+ runs-on : ${{ vars.BASE_RUNNER_TYPE || 'ubuntu-latest' }}
294+ timeout-minutes : 40
295+ environment : bitgo-express
296+ steps :
297+ - name : Checkout BitGoJS repository
298+ uses : actions/checkout@v6
299+ with :
300+ ref : ${{ needs.get-release-context.outputs.express-git-sha }}
301+
302+ - name : Set up Docker Buildx
303+ uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
304+
305+ - name : Log in to Docker Hub
306+ uses : docker/login-action@v4
307+ with :
308+ username : ${{ env.DOCKER_HUB_USERNAME }}
309+ password : ${{ secrets.DOCKER_HUB_API_KEY }}
310+
311+ - name : Generate build date
312+ id : build-date
313+ run : |
314+ BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
315+ echo "build-date=$BUILD_DATE" >> "$GITHUB_OUTPUT"
316+
317+ - name : Build and push Express Docker image
318+ id : docker-build
319+ uses : docker/build-push-action@v7
320+ with :
321+ context : .
322+ file : ./Dockerfile
323+ push : true
324+ tags : |
325+ bitgo/express:latest
326+ bitgo/express:${{ needs.get-release-context.outputs.express-version }}
327+ build-args : |
328+ VERSION=${{ needs.get-release-context.outputs.express-version }}
329+ BUILD_DATE=${{ steps.build-date.outputs.build-date }}
330+ GIT_HASH=${{ needs.get-release-context.outputs.express-git-sha }}
0 commit comments