|
1 | 1 | --- |
2 | 2 | name: Docker |
3 | | -# Build & Push rebuilds the Tenderdash docker image every time a release is published |
4 | | -# and pushes the image to https://hub.docker.com/r/dashpay/tenderdash/tags |
| 3 | +# Build & Push rebuilds the Tenderdash docker image every time a release is |
| 4 | +# published and pushes the image to https://hub.docker.com/r/dashpay/tenderdash |
5 | 5 | on: |
6 | 6 | workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag: |
| 9 | + type: string |
| 10 | + description: 'Docker tag' |
| 11 | + required: false |
7 | 12 | release: |
8 | 13 | types: |
9 | 14 | - published |
10 | 15 |
|
11 | 16 | jobs: |
12 | 17 | build: |
13 | | - runs-on: ubuntu-20.04 |
| 18 | + runs-on: ubuntu-22.04 |
14 | 19 | steps: |
15 | | - - uses: actions/checkout@v2.3.4 |
| 20 | + - uses: actions/checkout@v3 |
16 | 21 |
|
17 | 22 | - name: Set up QEMU |
18 | 23 | uses: docker/setup-qemu-action@master |
19 | 24 | with: |
20 | 25 | platforms: all |
21 | 26 |
|
22 | 27 | - name: Set up Docker Build |
23 | | - uses: docker/setup-buildx-action@v1.6.0 |
| 28 | + uses: docker/setup-buildx-action@v2.4.1 |
24 | 29 |
|
25 | 30 | - name: Login to DockerHub |
26 | 31 | if: ${{ github.event_name != 'pull_request' }} |
27 | | - uses: docker/login-action@v1.14.1 |
| 32 | + uses: docker/login-action@v2.0.0 |
28 | 33 | with: |
29 | 34 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
30 | 35 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
31 | 36 |
|
32 | 37 | - name: Set suffix to Docker tags |
33 | 38 | uses: actions/github-script@v6 |
34 | 39 | id: suffix |
| 40 | + if: ${{ github.event.release != null }} |
35 | 41 | with: |
36 | 42 | result-encoding: string |
37 | 43 | script: "return (context.payload.release.tag_name.includes('-dev') ? '-dev' : '');" |
38 | 44 |
|
| 45 | + - name: Determine TENDERMINT_BUILD_OPTIONS |
| 46 | + uses: actions/github-script@v6 |
| 47 | + id: TENDERMINT_BUILD_OPTIONS |
| 48 | + with: |
| 49 | + result-encoding: string |
| 50 | + script: | |
| 51 | + if (github.ref_type == 'tag' && !contains(github.ref_name,'-dev')) { |
| 52 | + return 'tenderdash,stable' |
| 53 | + } |
| 54 | + return 'tenderdash,dev,deadlock' |
| 55 | +
|
39 | 56 | - name: Set Docker tags and labels |
40 | 57 | id: docker_meta |
41 | 58 | uses: docker/metadata-action@v3 |
42 | 59 | with: |
43 | 60 | images: dashpay/tenderdash |
44 | 61 | tags: | |
| 62 | + type=semver,pattern={{version}},value=${{ github.event.inputs.tag }} |
| 63 | + type=raw,priority=650,value=${{ github.event.inputs.tag }},enable=${{ github.event.inputs.tag != '' }} |
| 64 | + type=ref,event=branch |
| 65 | + type=ref,event=pr |
45 | 66 | type=match,pattern=v(\d+),group=1 |
46 | 67 | type=match,pattern=v(\d+.\d+),group=1 |
47 | 68 | type=match,pattern=v(\d+.\d+.\d+),group=1 |
48 | 69 | type=match,pattern=v(.*),group=1,suffix=,enable=${{ contains(github.event.release.tag_name, '-dev') }} |
49 | 70 | flavor: | |
50 | | - latest=${{ !contains(github.event.release.tag_name, '-dev') }} |
| 71 | + latest=${{ github.event.release != null && !contains(github.event.release.tag_name, '-dev') }} |
51 | 72 | suffix=${{ steps.suffix.outputs.result }} |
52 | 73 |
|
| 74 | + # We build some dependencies and libraries separately. Layers are cached |
| 75 | + # on Docker Hub, as Github caches are not available for other branches. |
| 76 | + - name: Build and cache image with dependencies |
| 77 | + id: docker_bls |
| 78 | + uses: docker/build-push-action@v4.0.0 |
| 79 | + with: |
| 80 | + context: . |
| 81 | + file: ./DOCKER/Dockerfile |
| 82 | + platforms: linux/amd64,linux/arm64 |
| 83 | + target: base |
| 84 | + push: false |
| 85 | + cache-from: | |
| 86 | + type=registry,ref=dashpay/tenderdash:buildcache-deps |
| 87 | + cache-to: | |
| 88 | + type=registry,ref=dashpay/tenderdash:buildcache-deps,mode=max |
| 89 | + build-args: | |
| 90 | + TENDERMINT_BUILD_OPTIONS="${{ steps.TENDERMINT_BUILD_OPTIONS.outputs.result }}" |
| 91 | +
|
53 | 92 | - name: Publish to Docker Hub |
54 | | - uses: docker/build-push-action@v2.9.0 |
| 93 | + id: docker_build |
| 94 | + uses: docker/build-push-action@v4.0.0 |
55 | 95 | with: |
56 | 96 | context: . |
57 | 97 | file: ./DOCKER/Dockerfile |
58 | 98 | platforms: linux/amd64,linux/arm64 |
59 | 99 | push: ${{ github.event_name != 'pull_request' }} |
60 | 100 | tags: ${{ steps.docker_meta.outputs.tags }} |
61 | 101 | labels: ${{ steps.docker_meta.outputs.labels }} |
62 | | - cache-from: type=gha |
| 102 | + cache-from: | |
| 103 | + type=gha |
| 104 | + type=registry,ref=dashpay/tenderdash:buildcache-deps |
63 | 105 | cache-to: type=gha,mode=max |
64 | | - |
| 106 | + build-args: | |
| 107 | + TENDERMINT_BUILD_OPTIONS="${{ steps.TENDERMINT_BUILD_OPTIONS.outputs.result }}" |
65 | 108 | - name: Show Docker image digest |
66 | 109 | run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments