Skip to content

Commit aa13d47

Browse files
committed
Publish DogeOS rollup-node images from branches
1 parent c2d445b commit aa13d47

1 file changed

Lines changed: 171 additions & 72 deletions

File tree

.github/workflows/release.yml

Lines changed: 171 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,179 @@
1-
name: Docker
1+
name: Build and Push Docker Image
22

33
on:
44
push:
5+
branches:
6+
- main
7+
- develop
58
tags:
6-
- '*'
7-
release:
8-
types: [published]
9+
- "v*"
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- ".github/workflows/release.yml"
15+
- ".cargo/**"
16+
- "Cargo.lock"
17+
- "Cargo.toml"
18+
- "Dockerfile"
19+
- "crates/**"
20+
workflow_dispatch:
21+
inputs:
22+
tag:
23+
description: "Image tag"
24+
required: true
25+
default: "latest"
26+
type: string
27+
build_arm64:
28+
description: "Build arm64 image"
29+
required: true
30+
type: boolean
31+
default: false
32+
33+
env:
34+
IMAGE_NAME: dogeos69/rollup-node
935

1036
jobs:
11-
build-and-push:
12-
runs-on:
13-
group: scroll-reth-runner-group
14-
permissions: {}
37+
build-and-publish:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
1541

1642
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v6
19-
with:
20-
persist-credentials: false
21-
22-
- name: Set up QEMU
23-
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
24-
25-
- name: Set up Docker Buildx
26-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
27-
with:
28-
cache-binary: false
29-
30-
- name: Extract docker metadata (stable)
31-
id: meta-stable
32-
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
33-
with:
34-
images: scrolltech/rollup-node
35-
tags: |
36-
type=ref,event=tag,enable=${{ github.event_name == 'push' }}
37-
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
38-
flavor: |
39-
latest=false
40-
41-
- name: Extract docker metadata (nightly)
42-
id: meta-nightly
43-
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
44-
with:
45-
images: scrolltech/rollup-node
46-
tags: |
47-
type=ref,event=tag,enable=${{ github.event_name == 'push' }},suffix=-nightly
48-
type=raw,value=latest-nightly,enable=${{ github.event_name == 'release' }}
49-
flavor: |
50-
latest=false
51-
52-
- name: Login to Docker Hub
53-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 #v3.7.0
54-
with:
55-
username: ${{ secrets.DOCKERHUB_USERNAME }}
56-
password: ${{ secrets.DOCKERHUB_TOKEN }}
57-
58-
- name: Build docker image (stable)
59-
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
60-
with:
61-
context: .
62-
file: Dockerfile
63-
push: true
64-
tags: ${{ steps.meta-stable.outputs.tags }}
65-
labels: ${{ steps.meta-stable.outputs.labels }}
66-
cache-from: type=gha,scope=${{ github.workflow }}-stable
67-
cache-to: type=gha,scope=${{ github.workflow }}-stable
68-
69-
- name: Build docker image (nightly)
70-
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
71-
with:
72-
context: .
73-
file: Dockerfile
74-
push: true
75-
tags: ${{ steps.meta-nightly.outputs.tags }}
76-
labels: ${{ steps.meta-nightly.outputs.labels }}
77-
build-args: |
78-
CARGO_FEATURES=js-tracer
79-
cache-from: type=gha,scope=${{ github.workflow }}-nightly
80-
cache-to: type=gha,scope=${{ github.workflow }}-nightly
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
- name: Extract version from Cargo.toml
47+
run: |
48+
VERSION=$(grep -A 3 '^\[workspace\.package\]' Cargo.toml | grep '^version = ' | sed 's/version = "\(.*\)"/\1/')
49+
echo "WORKSPACE_VERSION=$VERSION" >> "$GITHUB_ENV"
50+
51+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
52+
MINOR=$(echo "$VERSION" | cut -d. -f2)
53+
PATCH=$(echo "$VERSION" | cut -d. -f3)
54+
55+
echo "VERSION_MAJOR=$MAJOR" >> "$GITHUB_ENV"
56+
echo "VERSION_MINOR=$MINOR" >> "$GITHUB_ENV"
57+
echo "VERSION_PATCH=$PATCH" >> "$GITHUB_ENV"
58+
59+
- name: Set image tags and environment
60+
run: |
61+
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_ENV"
62+
echo "VCS_REF=${GITHUB_SHA:0:8}" >> "$GITHUB_ENV"
63+
64+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
65+
MANUAL_TAG="${{ github.event.inputs.tag }}"
66+
TAGS="${IMAGE_NAME}:${MANUAL_TAG}"
67+
ENVIRONMENT="manual"
68+
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
69+
TAG_NAME="${GITHUB_REF_NAME}"
70+
VERSION="${TAG_NAME#v}"
71+
72+
if [[ "$VERSION" =~ -(alpha|beta|rc) ]]; then
73+
ENVIRONMENT="devnet"
74+
TAGS="${IMAGE_NAME}:${TAG_NAME}"
75+
TAGS="${TAGS},${IMAGE_NAME}:${VERSION}"
76+
TAGS="${TAGS},${IMAGE_NAME}:${VERSION}-${GITHUB_SHA:0:8}"
77+
else
78+
ENVIRONMENT="testnet"
79+
TAGS="${IMAGE_NAME}:${TAG_NAME}"
80+
TAGS="${TAGS},${IMAGE_NAME}:${WORKSPACE_VERSION}"
81+
TAGS="${TAGS},${IMAGE_NAME}:${WORKSPACE_VERSION}-${GITHUB_SHA:0:8}"
82+
TAGS="${TAGS},${IMAGE_NAME}:${VERSION_MAJOR}.${VERSION_MINOR}"
83+
TAGS="${TAGS},${IMAGE_NAME}:${VERSION_MAJOR}"
84+
TAGS="${TAGS},${IMAGE_NAME}:latest-testnet"
85+
TAGS="${TAGS},${IMAGE_NAME}:latest-devnet"
86+
fi
87+
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
88+
ENVIRONMENT="testnet"
89+
TAGS="${IMAGE_NAME}:latest-testnet"
90+
TAGS="${TAGS},${IMAGE_NAME}:${GITHUB_SHA:0:8}"
91+
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
92+
ENVIRONMENT="devnet"
93+
TAGS="${IMAGE_NAME}:latest-devnet"
94+
TAGS="${TAGS},${IMAGE_NAME}:${GITHUB_SHA:0:8}"
95+
else
96+
ENVIRONMENT="ephemeral"
97+
TAGS="${IMAGE_NAME}:${GITHUB_SHA:0:8}"
98+
fi
99+
100+
echo "ENVIRONMENT=$ENVIRONMENT" >> "$GITHUB_ENV"
101+
echo "DOCKER_TAGS=$TAGS" >> "$GITHUB_ENV"
102+
echo "Docker tags: $TAGS"
103+
104+
- name: Set platform
105+
run: |
106+
PLATFORM="linux/amd64"
107+
108+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.build_arm64 }}" == "true" ]]; then
109+
PLATFORM="linux/amd64,linux/arm64"
110+
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
111+
PLATFORM="linux/amd64,linux/arm64"
112+
fi
113+
114+
echo "PLATFORM=$PLATFORM" >> "$GITHUB_ENV"
115+
echo "Docker platform: $PLATFORM"
116+
117+
- name: Set up QEMU
118+
if: ${{ github.ref_type == 'tag' || (github.event_name == 'workflow_dispatch' && github.event.inputs.build_arm64 == 'true') }}
119+
uses: docker/setup-qemu-action@v3
120+
121+
- name: Set up Docker Buildx
122+
uses: docker/setup-buildx-action@v3
123+
124+
- name: Login to Docker Hub
125+
if: ${{ github.event_name != 'pull_request' }}
126+
uses: docker/login-action@v3
127+
with:
128+
username: ${{ secrets.DOCKERHUB_USERNAME }}
129+
password: ${{ secrets.DOCKERHUB_TOKEN }}
130+
131+
- name: Build Docker image
132+
if: ${{ github.event_name == 'pull_request' }}
133+
uses: docker/build-push-action@v5
134+
with:
135+
context: .
136+
file: Dockerfile
137+
push: false
138+
platforms: ${{ env.PLATFORM }}
139+
tags: ${{ env.DOCKER_TAGS }}
140+
labels: |
141+
org.opencontainers.image.title=rollup-node
142+
org.opencontainers.image.description=DogeOS rollup-node service
143+
org.opencontainers.image.version=${{ env.WORKSPACE_VERSION }}
144+
org.opencontainers.image.created=${{ env.BUILD_DATE }}
145+
org.opencontainers.image.revision=${{ github.sha }}
146+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
147+
dogeos.environment=${{ env.ENVIRONMENT }}
148+
dogeos.version.major=${{ env.VERSION_MAJOR }}
149+
dogeos.version.minor=${{ env.VERSION_MINOR }}
150+
dogeos.version.patch=${{ env.VERSION_PATCH }}
151+
dogeos.git.sha=${{ env.VCS_REF }}
152+
dogeos.git.branch=${{ github.ref_name }}
153+
154+
- name: Build and push Docker image
155+
if: ${{ github.event_name != 'pull_request' }}
156+
uses: docker/build-push-action@v5
157+
with:
158+
context: .
159+
file: Dockerfile
160+
push: true
161+
platforms: ${{ env.PLATFORM }}
162+
tags: ${{ env.DOCKER_TAGS }}
163+
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
164+
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
165+
labels: |
166+
org.opencontainers.image.title=rollup-node
167+
org.opencontainers.image.description=DogeOS rollup-node service
168+
org.opencontainers.image.version=${{ env.WORKSPACE_VERSION }}
169+
org.opencontainers.image.created=${{ env.BUILD_DATE }}
170+
org.opencontainers.image.revision=${{ github.sha }}
171+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
172+
dogeos.environment=${{ env.ENVIRONMENT }}
173+
dogeos.version.major=${{ env.VERSION_MAJOR }}
174+
dogeos.version.minor=${{ env.VERSION_MINOR }}
175+
dogeos.version.patch=${{ env.VERSION_PATCH }}
176+
dogeos.git.sha=${{ env.VCS_REF }}
177+
dogeos.git.branch=${{ github.ref_name }}
178+
env:
179+
DOCKER_BUILDKIT: 1

0 commit comments

Comments
 (0)