|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + branches: |
| 8 | + - master |
| 9 | + |
| 10 | +env: |
| 11 | + REGISTRY: ghcr.io |
| 12 | + REGISTRY_DOCKERHUB: docker.io |
| 13 | + IMAGE_NAME: ${{ github.repository }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + goreleaser: |
| 17 | + runs-on: ubuntu-20.04 |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + |
| 21 | + - name: Unshallow |
| 22 | + run: git fetch --prune --unshallow |
| 23 | + - name: Set up Go |
| 24 | + uses: actions/setup-go@v3 |
| 25 | + with: |
| 26 | + go-version: 1.20.x |
| 27 | + - name: Run GoReleaser |
| 28 | + uses: goreleaser/[email protected] |
| 29 | + with: |
| 30 | + version: latest |
| 31 | + args: release --rm-dist |
| 32 | + env: |
| 33 | + GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }} |
| 34 | + |
| 35 | + image: |
| 36 | + runs-on: ubuntu-20.04 |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + |
| 40 | + - name: Setup Docker buildx |
| 41 | + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf |
| 42 | + - name: Log into registry ${{ env.REGISTRY }} |
| 43 | + if: github.event_name != 'pull_request' |
| 44 | + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c |
| 45 | + with: |
| 46 | + registry: ${{ env.REGISTRY }} |
| 47 | + username: ${{ github.actor }} |
| 48 | + password: ${{ secrets.GH_PUBLISH_SECRETS }} |
| 49 | + - name: Extract Docker metadata |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 52 | + with: |
| 53 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 54 | + - name: Build and push Docker image |
| 55 | + id: build-and-push |
| 56 | + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a |
| 57 | + with: |
| 58 | + context: . |
| 59 | + push: ${{ github.event_name != 'pull_request' }} |
| 60 | + tags: ${{ steps.meta.outputs.tags }} |
| 61 | + labels: ${{ steps.meta.outputs.labels }} |
| 62 | + platforms: linux/amd64,linux/arm64 |
| 63 | + cache-from: type=gha |
| 64 | + cache-to: type=gha,mode=max |
| 65 | + |
| 66 | + image-dockerhub: |
| 67 | + runs-on: ubuntu-20.04 |
| 68 | + steps: |
| 69 | + - name: Checkout |
| 70 | + |
| 71 | + - name: Setup Docker buildx |
| 72 | + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf |
| 73 | + - name: Log into registry ${{ env.REGISTRY_DOCKERHUB }} |
| 74 | + if: github.event_name != 'pull_request' |
| 75 | + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c |
| 76 | + with: |
| 77 | + registry: ${{ env.REGISTRY_DOCKERHUB }} |
| 78 | + username: linuxsuren |
| 79 | + password: ${{ secrets.DOCKER_HUB_PUBLISH_SECRETS }} |
| 80 | + - name: Extract Docker metadata |
| 81 | + id: meta |
| 82 | + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 83 | + with: |
| 84 | + images: ${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }} |
| 85 | + - name: Build and push Docker image |
| 86 | + id: build-and-push |
| 87 | + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a |
| 88 | + with: |
| 89 | + context: . |
| 90 | + push: ${{ github.event_name != 'pull_request' }} |
| 91 | + tags: ${{ steps.meta.outputs.tags }} |
| 92 | + labels: ${{ steps.meta.outputs.labels }} |
| 93 | + platforms: linux/amd64,linux/arm64 |
| 94 | + cache-from: type=gha |
| 95 | + cache-to: type=gha,mode=max |
0 commit comments