Skip to content

Commit 0a6c4ea

Browse files
committed
Workflows updates
1 parent 3899f5d commit 0a6c4ea

3 files changed

Lines changed: 149 additions & 52 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
env:
2+
IMAGE_NAME: devcontainer-smart-contracts-rust
3+
REGISTRY_HOSTNAME: multiversx
4+
5+
name: Build Docker image - rust (PR)
6+
7+
on:
8+
pull_request:
9+
10+
jobs:
11+
build-docker-image:
12+
strategy:
13+
matrix:
14+
runner: [ubuntu-latest, ubuntu-24.04-arm]
15+
runs-on: ${{ matrix.runner }}
16+
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v5
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Build image
25+
uses: docker/build-push-action@v6
26+
with:
27+
context: ./resources/smart-contracts-rust
28+
push: false
29+
file: ./resources/smart-contracts-rust/Dockerfile
30+
tags: ${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }}:pr-test

.github/workflows/publish-image-rust.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
env:
2+
IMAGE_NAME: devcontainer-smart-contracts-rust
3+
REGISTRY_HOSTNAME: multiversx
4+
5+
name: Publish Docker image - rust (release)
6+
7+
on:
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Simulate release version (e.g., v0.4.2)'
14+
required: false
15+
default: ''
16+
type: string
17+
18+
jobs:
19+
prepare:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
tags: ${{ steps.meta.outputs.tags }}
23+
tags-json: ${{ steps.meta.outputs.json }}
24+
labels: ${{ steps.meta.outputs.labels }}
25+
steps:
26+
- name: Check out the repo
27+
uses: actions/checkout@v4
28+
29+
- name: Compute version from template (release)
30+
id: version
31+
if: github.event_name == 'release'
32+
run: |
33+
VERSION=v$(jq -r '.["version"]' ./src/smart-contracts-rust/devcontainer-template.json)
34+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
35+
36+
- name: Extract metadata
37+
id: meta
38+
env:
39+
VERSION: ${{ steps.version.outputs.VERSION }}
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=raw,value=latest
45+
${{ (github.event_name == 'release' && format('type=raw,value={0}', env.VERSION)) || (github.event.inputs.version != '' && format('type=raw,value={0}', github.event.inputs.version)) || '' }}
46+
47+
build:
48+
strategy:
49+
matrix:
50+
arch:
51+
- { runner: ubuntu-latest, platform: linux/amd64, platform_tag: linux_amd64 }
52+
- { runner: ubuntu-24.04-arm, platform: linux/arm64, platform_tag: linux_arm64 }
53+
runs-on: ${{ matrix.arch.runner }}
54+
needs: prepare
55+
steps:
56+
- name: Check out the repo
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Log in to Docker Hub
63+
uses: docker/login-action@v3
64+
with:
65+
username: ${{ secrets.DOCKER_USERNAME }}
66+
password: ${{ secrets.DOCKER_PASSWORD }}
67+
68+
- name: Build and push by digest
69+
id: build
70+
uses: docker/build-push-action@v6
71+
with:
72+
context: ./resources/smart-contracts-rust
73+
file: ./resources/smart-contracts-rust/Dockerfile
74+
platforms: ${{ matrix.arch.platform }}
75+
labels: ${{ needs.prepare.outputs.labels }}
76+
outputs: type=image,name=${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
77+
78+
- name: Export digest
79+
run: |
80+
mkdir -p /tmp/digests
81+
digest="${{ steps.build.outputs.digest }}"
82+
touch "/tmp/digests/${digest#sha256:}"
83+
84+
- name: Upload digest
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: digests-${{ matrix.arch.platform_tag }}
88+
path: /tmp/digests/*
89+
if-no-files-found: error
90+
retention-days: 1
91+
92+
manifest:
93+
runs-on: ubuntu-latest
94+
needs: [prepare, build]
95+
96+
steps:
97+
- name: Download digests
98+
uses: actions/download-artifact@v4
99+
with:
100+
path: /tmp/digests
101+
pattern: digests-*
102+
merge-multiple: true
103+
104+
- name: Set up Docker Buildx
105+
uses: docker/setup-buildx-action@v3
106+
107+
- name: Log in to Docker Hub
108+
uses: docker/login-action@v3
109+
with:
110+
username: ${{ secrets.DOCKER_USERNAME }}
111+
password: ${{ secrets.DOCKER_PASSWORD }}
112+
113+
- name: Create and push manifest
114+
working-directory: /tmp/digests
115+
env:
116+
TAGS_JSON: ${{ needs.prepare.outputs.tags-json }}
117+
run: |
118+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$TAGS_JSON") \
119+
$(printf '${{ env.REGISTRY_HOSTNAME }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)

0 commit comments

Comments
 (0)