Build, Publish & Release (Bitcoin Core) #70
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| BUILD_CONTEXT: bitcoin | |
| 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.BUILD_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 |