-
Notifications
You must be signed in to change notification settings - Fork 4
185 lines (166 loc) · 7.76 KB
/
cksolo-build-publish.yml
File metadata and controls
185 lines (166 loc) · 7.76 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
name: Build, Publish & Release (CKPool Solo)
on:
workflow_dispatch: {}
schedule:
- cron: "31 5 * * *" # daily
concurrency:
group: cksolo
cancel-in-progress: false
env:
DOCKERHUB_REPO: magicdude4eva/cksolo
BUILD_CONTEXT: cksolo
DOCKERFILE_PATH: cksolo/Dockerfile
PLATFORM: linux/amd64
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write # to create a GitHub Release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect latest solobtc commit
id: latest
run: |
set -euo pipefail
# Get latest commit on branch 'solobtc'
fullsha=$(git ls-remote --heads https://bitbucket.org/ckolivas/ckpool-solo.git solobtc | awk '{print $1}')
test -n "$fullsha"
shortsha=${fullsha:0:12}
echo "fullsha=$fullsha" >> "$GITHUB_OUTPUT"
echo "shortsha=$shortsha" >> "$GITHUB_OUTPUT"
echo "Latest solobtc: $fullsha ($shortsha)"
- name: Skip if tag already on Docker Hub
id: hubcheck
run: |
set -euo pipefail
tag="solobtc-${{ steps.latest.outputs.shortsha }}"
code=$(curl -s -o /dev/null -w "%{http_code}" \
"https://hub.docker.com/v2/repositories/${{ env.DOCKERHUB_REPO }}/tags/${tag}")
echo "hub_status=$code" >> "$GITHUB_OUTPUT"
if [ "$code" = "200" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag $tag already exists - skipping."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "Tag $tag not found - will build."
fi
- name: Set up Buildx
if: steps.hubcheck.outputs.skip == 'false'
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: steps.hubcheck.outputs.skip == 'false'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
if: steps.hubcheck.outputs.skip == 'false'
id: build
uses: docker/build-push-action@v6
with:
context: ${{ env.BUILD_CONTEXT }}
file: ${{ env.DOCKERFILE_PATH }}
platforms: ${{ env.PLATFORM }}
push: true
build-args: |
CKPOOL_REF=${{ steps.latest.outputs.fullsha }}
tags: |
${{ env.DOCKERHUB_REPO }}:latest
${{ env.DOCKERHUB_REPO }}:solobtc-${{ steps.latest.outputs.shortsha }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=solobtc-${{ steps.latest.outputs.shortsha }}
org.opencontainers.image.title=cksolo
org.opencontainers.image.description=CKPool Solo - Lightweight stratum server for Bitcoin solo mining
- name: Update Docker Hub description from ./cksolo/README.md
if: steps.hubcheck.outputs.skip == 'false'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.DOCKERHUB_REPO }}
readme-filepath: ./cksolo/README.md
short-description: CKPool Solo - Lightweight stratum server for Bitcoin solo mining
- name: Prepare release artifacts
if: steps.hubcheck.outputs.skip == 'false'
run: |
set -euo pipefail
echo "${{ steps.latest.outputs.fullsha }}" > upstream-fullsha.txt
echo "solobtc-${{ steps.latest.outputs.shortsha }}" > image-tag.txt
echo "${{ steps.build.outputs.digest }}" > image-digest.txt
- name: Build commit changelog since last release
if: steps.hubcheck.outputs.skip == 'false'
id: changelog
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
new_full='${{ steps.latest.outputs.fullsha }}'
mkdir -p _artifacts
# Find previous cksolo release in this repo (if any) and get its upstream SHA
prev_tag=$(gh release list --limit 200 --json tagName,isDraft,isPrerelease,publishedAt \
--jq '[.[] | select(.tagName | startswith("cksolo-")) | select(.isDraft==false and .isPrerelease==false)]
| sort_by(.publishedAt) | last // empty | .tagName')
if [ -n "${prev_tag:-}" ]; then
echo "Prev release: $prev_tag"
gh release download "$prev_tag" -p upstream-fullsha.txt -O _artifacts/prev-upstream-fullsha.txt
prev_full=$(cat _artifacts/prev-upstream-fullsha.txt | tr -d '\r\n')
else
echo "No previous cksolo release found."
prev_full=""
fi
# Build commit list
echo "# Changes in ckpool-solo (solobtc)" > _artifacts/release-body.md
echo "" >> _artifacts/release-body.md
echo "**Upstream commit:** \`${new_full}\`" >> _artifacts/release-body.md
echo "" >> _artifacts/release-body.md
if [ -n "$prev_full" ]; then
echo "Comparing range: $prev_full..$new_full"
git clone --filter=blob:none https://bitbucket.org/ckolivas/ckpool-solo.git upstream
cd upstream
git checkout solobtc
# Ensure both commits exist locally
git fetch origin "$prev_full" "$new_full" --depth=1 || git fetch origin solobtc --unshallow || true
echo "" >> ../_artifacts/release-body.md
echo "## Commits since last release" >> ../_artifacts/release-body.md
echo "" >> ../_artifacts/release-body.md
# Format: shortsha subject (author)
if git merge-base --is-ancestor "$prev_full" "$new_full"; then
git log --no-merges --pretty=format:'- %h %s (%an)' "$prev_full..$new_full" >> ../_artifacts/release-body.md
else
echo "_Note: previous SHA is not an ancestor of the new SHA; showing short log of solobtc branch._" >> ../_artifacts/release-body.md
git log --no-merges --pretty=format:'- %h %s (%an)' -n 50 >> ../_artifacts/release-body.md
fi
cd ..
else
echo "_First release detected. Commit list not available._" >> _artifacts/release-body.md
fi
echo "" >> _artifacts/release-body.md
echo "## Docker Hub" >> _artifacts/release-body.md
echo "- https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=solobtc-${{ steps.latest.outputs.shortsha }}" >> _artifacts/release-body.md
echo "- https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=latest" >> _artifacts/release-body.md
echo "" >> _artifacts/release-body.md
echo "## Image digest" >> _artifacts/release-body.md
echo '```' >> _artifacts/release-body.md
echo "${{ steps.build.outputs.digest }}" >> _artifacts/release-body.md
echo '```' >> _artifacts/release-body.md
- name: Create GitHub Release in btc-fullnode-stack
if: steps.hubcheck.outputs.skip == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: cksolo-${{ steps.latest.outputs.shortsha }}
name: CKPool Solo (solobtc @ ${{ steps.latest.outputs.shortsha }})
target_commitish: ${{ github.sha }}
generate_release_notes: false
body_path: _artifacts/release-body.md
files: |
upstream-fullsha.txt
image-tag.txt
image-digest.txt
- name: Summary
run: |
echo "Upstream full SHA: ${{ steps.latest.outputs.fullsha }}"
echo "Short SHA: ${{ steps.latest.outputs.shortsha }}"
echo "Hub status: ${{ steps.hubcheck.outputs.hub_status }}"
echo "Skipped: ${{ steps.hubcheck.outputs.skip }}"