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