|
| 1 | +name: Build, Publish & Release (Fulcrum) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: {} |
| 5 | + schedule: |
| 6 | + - cron: "43 5 * * *" # daily |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: btc-fulcrum |
| 10 | + cancel-in-progress: false |
| 11 | + |
| 12 | +env: |
| 13 | + DOCKERHUB_REPO: magicdude4eva/btc-fulcrum |
| 14 | + BUILD_CONTEXT: fulcrum |
| 15 | + DOCKERFILE_PATH: fulcrum/Dockerfile |
| 16 | + PLATFORM: linux/amd64 |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-and-push: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: write # to create GitHub releases |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Detect latest Fulcrum version |
| 28 | + id: latest |
| 29 | + run: | |
| 30 | + set -euo pipefail |
| 31 | + # Use GitHub API to get the latest release tag (e.g. "v1.12.0") |
| 32 | + tag=$(curl -fsSL https://api.github.com/repos/cculianu/Fulcrum/releases/latest \ |
| 33 | + | grep -Eo '"tag_name":\s*"[^"]+"' | sed -E 's/.*"tag_name":\s*"([^"]+)".*/\1/') |
| 34 | + test -n "$tag" |
| 35 | + # Strip a leading "v" for Dockerfile's FULCRUM_VERSION arg |
| 36 | + ver=$(printf "%s" "$tag" | sed -E 's/^v//') |
| 37 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 38 | + echo "version=$ver" >> "$GITHUB_OUTPUT" |
| 39 | + echo "Latest Fulcrum: tag=$tag -> version=$ver" |
| 40 | +
|
| 41 | + - name: Skip if tag already on Docker Hub |
| 42 | + id: hubcheck |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | + ver='${{ steps.latest.outputs.version }}' |
| 46 | + code=$(curl -s -o /dev/null -w "%{http_code}" \ |
| 47 | + "https://hub.docker.com/v2/repositories/${{ env.DOCKERHUB_REPO }}/tags/${ver}") |
| 48 | + echo "hub_status=$code" >> "$GITHUB_OUTPUT" |
| 49 | + if [ "$code" = "200" ]; then |
| 50 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 51 | + echo "Tag $ver already exists - skipping." |
| 52 | + else |
| 53 | + echo "skip=false" >> "$GITHUB_OUTPUT" |
| 54 | + echo "Tag $ver not found - will build." |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Set up Buildx |
| 58 | + if: steps.hubcheck.outputs.skip == 'false' |
| 59 | + uses: docker/setup-buildx-action@v3 |
| 60 | + |
| 61 | + - name: Log in to Docker Hub |
| 62 | + if: steps.hubcheck.outputs.skip == 'false' |
| 63 | + uses: docker/login-action@v3 |
| 64 | + with: |
| 65 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 66 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Build and push |
| 69 | + if: steps.hubcheck.outputs.skip == 'false' |
| 70 | + id: build |
| 71 | + uses: docker/build-push-action@v6 |
| 72 | + with: |
| 73 | + context: ${{ env.BUILD_CONTEXT }} |
| 74 | + file: ${{ env.DOCKERFILE_PATH }} |
| 75 | + platforms: ${{ env.PLATFORM }} |
| 76 | + push: true |
| 77 | + build-args: | |
| 78 | + FULCRUM_VERSION=${{ steps.latest.outputs.version }} |
| 79 | + tags: | |
| 80 | + ${{ env.DOCKERHUB_REPO }}:latest |
| 81 | + ${{ env.DOCKERHUB_REPO }}:${{ steps.latest.outputs.version }} |
| 82 | + labels: | |
| 83 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 84 | + org.opencontainers.image.version=${{ steps.latest.outputs.version }} |
| 85 | + org.opencontainers.image.title=btc-fulcrum |
| 86 | + org.opencontainers.image.description=Fulcrum - Electrum-style server for Bitcoin/BCH |
| 87 | +
|
| 88 | + - name: Update Docker Hub description from ./fulcrum/README.md |
| 89 | + if: steps.hubcheck.outputs.skip == 'false' |
| 90 | + uses: peter-evans/dockerhub-description@v4 |
| 91 | + with: |
| 92 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 93 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 94 | + repository: ${{ env.DOCKERHUB_REPO }} |
| 95 | + readme-filepath: ./fulcrum/README.md |
| 96 | + short-description: Fulcrum - Electrum-style server for Bitcoin/BCH |
| 97 | + |
| 98 | + - name: Prepare release artifacts |
| 99 | + if: steps.hubcheck.outputs.skip == 'false' |
| 100 | + run: | |
| 101 | + set -euo pipefail |
| 102 | + echo "${{ steps.latest.outputs.version }}" > fulcrum-version.txt |
| 103 | + echo "${{ steps.latest.outputs.tag }}" > upstream-tag.txt |
| 104 | + echo "${{ steps.build.outputs.digest }}" > image-digest.txt |
| 105 | +
|
| 106 | + - name: Create GitHub Release in btc-fullnode-stack |
| 107 | + if: steps.hubcheck.outputs.skip == 'false' |
| 108 | + uses: softprops/action-gh-release@v2 |
| 109 | + with: |
| 110 | + tag_name: fulcrum-${{ steps.latest.outputs.version }} |
| 111 | + name: Fulcrum ${{ steps.latest.outputs.version }} |
| 112 | + target_commitish: ${{ github.sha }} |
| 113 | + generate_release_notes: true |
| 114 | + body: | |
| 115 | + Fulcrum **${{ steps.latest.outputs.version }}** image published. |
| 116 | +
|
| 117 | + Upstream: ${{ steps.latest.outputs.tag }} |
| 118 | +
|
| 119 | + Docker Hub: |
| 120 | + - https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=${{ steps.latest.outputs.version }} |
| 121 | + - https://hub.docker.com/r/${{ env.DOCKERHUB_REPO }}/tags?name=latest |
| 122 | +
|
| 123 | + Image digest: |
| 124 | + ``` |
| 125 | + ${{ steps.build.outputs.digest }} |
| 126 | + ``` |
| 127 | + files: | |
| 128 | + fulcrum-version.txt |
| 129 | + upstream-tag.txt |
| 130 | + image-digest.txt |
| 131 | +
|
| 132 | + - name: Summary |
| 133 | + run: | |
| 134 | + echo "Fulcrum version: ${{ steps.latest.outputs.version }}" |
| 135 | + echo "Upstream tag: ${{ steps.latest.outputs.tag }}" |
| 136 | + echo "Hub status: ${{ steps.hubcheck.outputs.hub_status }}" |
| 137 | + echo "Skipped: ${{ steps.hubcheck.outputs.skip }}" |
0 commit comments