Skip to content

Commit 84edc9b

Browse files
committed
feat(workflows): add release workflow for Docker images
1 parent a2699fd commit 84edc9b

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release Docker Images
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
auth-server-released:
7+
description: 'Set to true to push docker images.'
8+
required: true
9+
type: boolean
10+
default: false
11+
custom-tag:
12+
description: 'Optional tag name to apply in addition to ref/sha tags.'
13+
required: false
14+
default: ''
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
env:
21+
NODE_VERSION: '22.18.0'
22+
PNPM_VERSION: 9.15.0
23+
24+
jobs:
25+
docker-images:
26+
name: Build and Push
27+
if: ${{ github.event.inputs.auth-server-released == 'true' }}
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
app: [lit-auth-server, lit-login-server]
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Setup Node
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: ${{ env.NODE_VERSION }}
42+
43+
- name: Setup PNPM
44+
uses: pnpm/action-setup@v4
45+
with:
46+
version: ${{ env.PNPM_VERSION }}
47+
48+
- name: Install project dependencies
49+
run: pnpm install --frozen-lockfile
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Log in to GHCR
55+
uses: docker/login-action@v3
56+
with:
57+
registry: ghcr.io
58+
username: ${{ secrets.GHCR_USERNAME || github.repository_owner }}
59+
password: ${{ secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }}
60+
61+
- name: Extract Docker metadata
62+
id: meta
63+
uses: docker/metadata-action@v5
64+
with:
65+
images: ghcr.io/lit-protocol/${{ matrix.app }}
66+
tags: |
67+
type=ref,event=branch
68+
type=ref,event=tag
69+
type=sha
70+
type=raw,value=latest
71+
72+
- name: Build image with Nx target
73+
run: pnpm nx run ${{ matrix.app }}:docker-build
74+
75+
- name: Tag and push image
76+
env:
77+
IMAGE_NAME: ${{ matrix.app }}
78+
TAGS: ${{ steps.meta.outputs.tags }}
79+
CUSTOM_TAG: ${{ github.event.inputs.custom-tag }}
80+
run: |
81+
tags_to_push="$TAGS"
82+
if [ -n "$CUSTOM_TAG" ]; then
83+
tags_to_push="$tags_to_push"$'\n'"ghcr.io/lit-protocol/${IMAGE_NAME}:$CUSTOM_TAG"
84+
fi
85+
echo "$tags_to_push" | while IFS= read -r tag; do
86+
[ -z "$tag" ] && continue
87+
docker tag "$IMAGE_NAME" "$tag"
88+
docker push "$tag"
89+
done
90+
91+
skip:
92+
name: Skip Docker Release
93+
if: ${{ github.event.inputs.auth-server-released != 'true' }}
94+
runs-on: ubuntu-latest
95+
steps:
96+
- run: echo "Skipping docker image publish because auth-server release flag is false."

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ permissions:
1414
jobs:
1515
release:
1616
runs-on: ubuntu-latest
17+
# Enable this when we want to implement docker image release
18+
# outputs:
19+
# published: ${{ steps.changesets.outputs.published }}
20+
# auth_server_published: ${{ steps.auth_server_release.outputs.published }}
1721
steps:
1822
- name: Check NPM Token
1923
run: |
@@ -78,3 +82,22 @@ jobs:
7882
env:
7983
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8084
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
85+
86+
# - Was lit-auth-server part of the most recent release?
87+
# - Capture published packages
88+
# - Fallback to empty array if nothing was published
89+
# - Search for the specific package
90+
# - Using jq, it inspects the JSON array of published packages, checking if any have a .name equal to either lit-auth-server or @lit-protocol/lit-auth-server.
91+
# - If the package is found, it writes published=true into the GitHub Actions step output.
92+
# - name: Check for lit-auth-server release
93+
# id: auth_server_release
94+
# run: |
95+
# packages='${{ steps.changesets.outputs.publishedPackages }}'
96+
# if [ -z "$packages" ]; then
97+
# packages='[]'
98+
# fi
99+
# if echo "$packages" | jq -e '.[] | select(.name == "lit-auth-server" or .name == "@lit-protocol/lit-auth-server")' > /dev/null; then
100+
# echo "published=true" >> "$GITHUB_OUTPUT"
101+
# else
102+
# echo "published=false" >> "$GITHUB_OUTPUT"
103+
# fi

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ git commit -m "chore: release v0.0.1"
9898
bunx changeset publish
9999
```
100100

101+
## Releasing Docker Images
102+
103+
- Trigger the `Release Docker Images` GitHub Action (`.github/workflows/release-docker-images.yml`) from the Actions tab once the desired changes are on the branch you want to release from.
104+
- When starting the workflow, select the branch ref, set `auth-server-released` to true, and optionally provide a `custom-tag` to add an extra image tag alongside the branch/commit/`latest` tags.
105+
- The job builds both `lit-auth-server` and `lit-login-server` via their Nx `docker-build` targets and pushes images to `ghcr.io/lit-protocol/<app>` using the repo's `GITHUB_TOKEN` (or the `GHCR_USERNAME`/`GHCR_TOKEN` secrets if you supply them).
106+
- Leave `auth-server-released` unchecked to perform a no-op dry run and confirm the workflow is available without publishing images.
107+
101108
## Keeping the contract address and ABIs in sync with the latest changes
102109

103110
This command must be run manually and is NOT part of the build process, as it requires a GitHub API key.

0 commit comments

Comments
 (0)