|
4 | 4 | release:
|
5 | 5 | types: [created]
|
6 | 6 |
|
| 7 | +env: |
| 8 | + DOCKER_IMAGE_NAME: unstoppableswap/asb |
| 9 | + |
7 | 10 | jobs:
|
8 | 11 | build_binaries:
|
9 | 12 | name: Build
|
|
82 | 85 | run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help
|
83 | 86 |
|
84 | 87 | - id: create-archive-name
|
85 |
| - shell: python # Use python to have a prettier name for the archive on Windows. |
| 88 | + shell: python |
86 | 89 | run: |
|
87 | 90 | import platform
|
88 | 91 | os_info = platform.uname()
|
@@ -122,3 +125,51 @@ jobs:
|
122 | 125 | asset_path: ./${{ steps.create-archive-name.outputs.archive }}
|
123 | 126 | asset_name: ${{ steps.create-archive-name.outputs.archive }}
|
124 | 127 | asset_content_type: application/gzip
|
| 128 | + |
| 129 | + build_and_push_docker: |
| 130 | + name: Build and Push Docker Image |
| 131 | + runs-on: ubuntu-latest |
| 132 | + needs: build_binaries |
| 133 | + steps: |
| 134 | + - name: Checkout code |
| 135 | + |
| 136 | + with: |
| 137 | + ref: ${{ github.event.release.target_commitish }} |
| 138 | + |
| 139 | + - name: Set up Docker Buildx |
| 140 | + uses: docker/setup-buildx-action@v2 |
| 141 | + |
| 142 | + - name: Login to DockerHub |
| 143 | + uses: docker/login-action@v2 |
| 144 | + with: |
| 145 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 146 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 147 | + |
| 148 | + - name: Set Docker tags |
| 149 | + id: docker_tags |
| 150 | + run: | |
| 151 | + if [[ ${{ github.event.release.tag_name }} == "preview" ]]; then |
| 152 | + echo "::set-output name=preview::true" |
| 153 | + else |
| 154 | + echo "::set-output name=preview::false" |
| 155 | + fi |
| 156 | +
|
| 157 | + - name: Build and push Docker image |
| 158 | + uses: docker/build-push-action@v4 |
| 159 | + with: |
| 160 | + context: . |
| 161 | + file: ./Dockerfile |
| 162 | + push: true |
| 163 | + tags: | |
| 164 | + ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} |
| 165 | + ${{ env.DOCKER_IMAGE_NAME }}:latest |
| 166 | + if: steps.docker_tags.outputs.preview == 'false' |
| 167 | + |
| 168 | + - name: Build and push Docker image without latest tag (preview release) |
| 169 | + uses: docker/build-push-action@v4 |
| 170 | + with: |
| 171 | + context: . |
| 172 | + file: ./Dockerfile |
| 173 | + push: true |
| 174 | + tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }} |
| 175 | + if: steps.docker_tags.outputs.preview == 'true' |
0 commit comments