-
-
Notifications
You must be signed in to change notification settings - Fork 4
134 lines (119 loc) · 4.84 KB
/
bitcoin-build-publish.yml
File metadata and controls
134 lines (119 loc) · 4.84 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
name: Build, Publish & Release (Bitcoin Core)
on:
workflow_dispatch: {}
schedule:
- cron: "17 5 * * *" # daily
concurrency:
group: btc-bitcoin
cancel-in-progress: false
env:
DOCKERHUB_REPO: magicdude4eva/btc-bitcoin
DOCKER_CONTEXT: .
DOCKERFILE_PATH: bitcoin/Dockerfile
PLATFORM: linux/amd64
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write # needed to create a GitHub Release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect latest Bitcoin Core version (from /en/download/)
id: latest
run: |
set -euo pipefail
html=$(curl -fsSL https://bitcoincore.org/en/download/)
ver=$(printf "%s" "$html" \
| grep -Eo 'Latest version: *[0-9]+(\.[0-9]+)+' \
| head -n1 | sed -E 's/.*:[[:space:]]*//')
# Fallback to /en/releases/ if needed
if [ -z "${ver:-}" ]; then
rel=$(curl -fsSL https://bitcoincore.org/en/releases/)
ver=$(printf "%s" "$rel" \
| grep -Eo 'Bitcoin Core [0-9]+(\.[0-9]+)+' \
| head -n1 | sed -E 's/Bitcoin Core //')
fi
test -n "$ver"
echo "version=$ver" >> "$GITHUB_OUTPUT"
echo "Latest detected: $ver"
- name: Skip if tag already on Docker Hub
id: hubcheck
run: |
set -euo pipefail
ver='${{ steps.latest.outputs.version }}'
code=$(curl -s -o /dev/null -w "%{http_code}" \
"https://hub.docker.com/v2/repositories/${{ env.DOCKERHUB_REPO }}/tags/${ver}")
echo "hub_status=$code" >> "$GITHUB_OUTPUT"
if [ "$code" = "200" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag $ver already exists - skipping."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "Tag $ver 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 Docker image
if: steps.hubcheck.outputs.skip == 'false'
id: build
uses: docker/build-push-action@v6
with:
context: ${{ env.DOCKER_CONTEXT }}
file: ${{ env.DOCKERFILE_PATH }}
platforms: ${{ env.PLATFORM }}
push: true
build-args: |
BITCOIN_VERSION=${{ steps.latest.outputs.version }}
tags: |
${{ env.DOCKERHUB_REPO }}:latest
${{ env.DOCKERHUB_REPO }}:${{ steps.latest.outputs.version }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ steps.latest.outputs.version }}
org.opencontainers.image.title=btc-bitcoin
org.opencontainers.image.description=Bitcoin Core full node image for Synology NAS
- name: Prepare release artifacts
if: steps.hubcheck.outputs.skip == 'false'
run: |
set -euo pipefail
echo "${{ steps.latest.outputs.version }}" > bitcoin-version.txt
# build-push-action outputs .digest for the manifest list/image
echo "${{ steps.build.outputs.digest }}" > image-digest.txt
- name: Update Docker Hub description from ./bitcoin/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: ./bitcoin/README.md
short-description: Bitcoin Core full node image for Synology NAS, tailored for local solo mining and full validation
- name: Create GitHub Release
if: steps.hubcheck.outputs.skip == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: bitcoin-${{ steps.latest.outputs.version }}
name: Bitcoin Core ${{ steps.latest.outputs.version }}
target_commitish: ${{ github.sha }}
generate_release_notes: true
body: |
New Bitcoin Core image published.
Version: **${{ steps.latest.outputs.version }}**
Docker Hub:
- https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=${{ steps.latest.outputs.version }}
- https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=latest
Image digest:
```
${{ steps.build.outputs.digest }}
```
files: |
bitcoin-version.txt
image-digest.txt