generated from opentensor/bittensor-subnet-template
-
Notifications
You must be signed in to change notification settings - Fork 13
83 lines (73 loc) · 2.62 KB
/
docker-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: 'Build and Publish Images to Docker Hub'
on:
push:
branches:
- feature-docker-compose
tags:
- 'v*' # Only trigger on version tags
jobs:
docker:
runs-on: ubuntu-latest
timeout-minutes: 240 # Increased timeout for ARM64 builds
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Tag generation with latest and release handling
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: masaengineering/masa-bittensor
tags: |
# Always push latest
type=raw,value=latest
# Branch builds with timestamp
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
# SHA with timestamp
type=sha,format=short,prefix=sha-,suffix=-{{date 'YYYYMMDDHHmmss'}}
# Version tags (v1.2.3 -> 1.2.3, latest)
type=semver,pattern={{version}},value=${{ github.ref_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }}
type=semver,pattern={{major}},value=${{ github.ref_name }}
# Debug step to see what tags will be used
- name: Debug Docker Tags
run: |
echo "Tags to be used:"
echo "${{ steps.meta.outputs.tags }}"
echo "Is this a release? ${{ startsWith(github.ref, 'refs/tags/v') }}"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Verify the push was successful
- name: Verify Push
run: |
echo "Verifying pushed images..."
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do
echo "Checking tag: $tag"
docker pull $tag
done
# Announce the release in the logs
- name: Announce Release
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "🎉 Released version ${GITHUB_REF#refs/tags/v}"
echo "Published tags:"
echo "${{ steps.meta.outputs.tags }}"