-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (190 loc) · 8.06 KB
/
compose-weekly-build.yml
File metadata and controls
231 lines (190 loc) · 8.06 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Weekly Docker Compose RISC-V64 Build
on:
schedule:
# Run every Sunday at 03:00 UTC (1 hour after Docker build)
- cron: '0 3 * * 0'
workflow_dispatch:
inputs:
compose_ref:
description: 'Compose ref to build (branch/tag/commit)'
required: false
default: 'main'
permissions:
contents: write
issues: write
actions: write
jobs:
build-compose:
runs-on: [self-hosted, riscv64]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
# Don't checkout all submodules - we only need compose
submodules: false
fetch-depth: 0
- name: Checkout compose submodule only
run: |
# Only init and update the compose submodule (skip moby, cli, cagent)
git submodule update --init --depth 1 compose
cd compose
git fetch origin --tags
git checkout ${{ github.event.inputs.compose_ref || 'main' }}
# Pull only if it's a branch (not a tag)
if git show-ref --verify --quiet refs/remotes/origin/${{ github.event.inputs.compose_ref || 'main' }}; then
git pull origin ${{ github.event.inputs.compose_ref || 'main' }}
fi
- name: Build docker-compose binary
run: |
set -euo pipefail
cd compose
# Set version from git tag
VERSION=$(git describe --tags --always)
echo "Building compose version: $VERSION"
# Build with version info and explicit GOOS/GOARCH
export GOOS=linux GOARCH=riscv64 CGO_ENABLED=0
make VERSION="$VERSION"
# Verify binary exists
ls -lh bin/build/docker-compose
- name: Extract binary
run: |
DATE=$(date +%Y%m%d)
mkdir -p release-compose-$DATE
# Copy binary
cp compose/bin/build/docker-compose release-compose-$DATE/
chmod +x release-compose-$DATE/docker-compose
# Get version
./release-compose-$DATE/docker-compose version > release-compose-$DATE/VERSION.txt 2>&1 || echo "Version command not available"
ls -lh release-compose-$DATE/
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Ensure gh is installed
if ! command -v gh >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y gh || true
fi
DATE=$(date +%Y%m%d)
COMPOSE_REF="${{ github.event.inputs.compose_ref || 'main' }}"
# Get version from submodule
cd compose
COMPOSE_VERSION=$(git describe --tags --always)
cd ..
# Determine release version (handle both v2.40.1 and 2.40.1 formats)
if [[ "$COMPOSE_REF" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
# Official release: v2.26.1 or 2.26.1 -> compose-v2.26.1-riscv64
CLEAN_REF="${COMPOSE_REF#v}"
RELEASE_VERSION="compose-v${CLEAN_REF}-riscv64"
RELEASE_TITLE="Docker Compose v${CLEAN_REF} for RISC-V64"
VERSION_INFO="**Docker Compose Version:** v${CLEAN_REF}"
else
# Development build
RELEASE_VERSION="compose-v${DATE}-dev"
RELEASE_TITLE="Docker Compose RISC-V64 Development Build ${DATE}"
VERSION_INFO="**Compose Branch:** ${COMPOSE_REF}
**Compose Version:** ${COMPOSE_VERSION}"
fi
cat > release-notes.md << EOF
Automated build of Docker Compose v2 plugin for RISC-V64
${VERSION_INFO}
**Build Date:** $(date -u +%Y-%m-%d)
**Architecture:** riscv64
**Installation:**
\`\`\`bash
# Download binary
wget https://github.com/gounthar/docker-for-riscv64/releases/download/${RELEASE_VERSION}/docker-compose
chmod +x docker-compose
# Install as Docker CLI plugin
sudo mkdir -p /usr/libexec/docker/cli-plugins
sudo mv docker-compose /usr/libexec/docker/cli-plugins/
# Verify
docker compose version
\`\`\`
**Backward Compatibility:**
\`\`\`bash
# Create symlink for legacy docker-compose command
sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose
docker-compose version
\`\`\`
**Build Command:**
\`\`\`bash
cd compose
make VERSION=${COMPOSE_VERSION}
\`\`\`
Automated build on RISC-V64 hardware
EOF
# For development builds, delete existing release if it exists
if [[ "$RELEASE_VERSION" =~ -dev$ ]]; then
echo "Checking for existing development release..."
if gh release view "${RELEASE_VERSION}" >/dev/null 2>&1; then
echo "Deleting existing release ${RELEASE_VERSION}..."
gh release delete "${RELEASE_VERSION}" --yes
fi
fi
gh release create "${RELEASE_VERSION}" \
--title "${RELEASE_TITLE}" \
--notes-file release-notes.md \
release-compose-$DATE/*
- name: Close tracking issue
if: ${{ success() }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
COMPOSE_REF="${{ github.event.inputs.compose_ref || 'main' }}"
# Only close issues for official releases (not dev builds)
if [[ "$COMPOSE_REF" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
# Normalize version format to match release creation
CLEAN_REF="${COMPOSE_REF#v}"
VERSION_TAG="v${CLEAN_REF}"
RELEASE_VERSION="compose-${VERSION_TAG}-riscv64"
echo "Searching for tracking issue for Docker Compose ${VERSION_TAG}..."
# Find the issue by label and title (if tracking workflow exists)
ISSUE_NUMBER=$(gh issue list \
--label "build-in-progress,compose-release" \
--state open \
--limit 200 \
--json number,title \
--jq ".[] | select(.title | contains(\"${VERSION_TAG}\")) | .number" \
| head -n1)
if [ -n "$ISSUE_NUMBER" ]; then
echo "Found tracking issue #${ISSUE_NUMBER}"
# Comment on the issue with release link
gh issue comment "$ISSUE_NUMBER" \
--body "Build completed successfully! Release published: https://github.com/${{ github.repository }}/releases/tag/${RELEASE_VERSION}"
# Close the issue
gh issue close "$ISSUE_NUMBER" \
--reason completed \
--comment "Automatically closing - release published."
echo "Issue #${ISSUE_NUMBER} closed successfully"
else
echo "No tracking issue found for ${VERSION_TAG}"
fi
else
echo "Skipping issue closing for development build"
fi
- name: Trigger package builds
if: ${{ success() }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
COMPOSE_REF="${{ github.event.inputs.compose_ref || 'main' }}"
# Only trigger package builds for official releases (not dev builds)
if [[ "$COMPOSE_REF" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
CLEAN_REF="${COMPOSE_REF#v}"
RELEASE_TAG="compose-v${CLEAN_REF}-riscv64"
echo "Triggering package builds for $RELEASE_TAG..."
# Trigger Debian package build
gh workflow run build-compose-package.yml -f release_tag="$RELEASE_TAG"
echo "✓ Triggered build-compose-package.yml"
# Trigger RPM package build
gh workflow run build-compose-rpm.yml -f release_tag="$RELEASE_TAG"
echo "✓ Triggered build-compose-rpm.yml"
echo ""
echo "Package builds triggered successfully!"
echo "Monitor progress: gh run list --workflow=build-compose-package.yml --limit 1"
else
echo "Skipping package builds for development build"
fi