|
9 | 9 | publish: |
10 | 10 | name: Publish |
11 | 11 | runs-on: ubuntu-latest |
12 | | - timeout-minutes: 10 |
| 12 | + timeout-minutes: 20 |
| 13 | + |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + packages: write |
13 | 17 |
|
14 | 18 | steps: |
15 | | - - uses: actions/checkout@v3 |
| 19 | + - name: 📦 Checkout repository |
| 20 | + uses: actions/checkout@v3 |
16 | 21 | with: |
17 | 22 | fetch-depth: 0 |
18 | 23 |
|
19 | | - - uses: actions/setup-go@v4 |
20 | | - |
21 | | - - uses: docker/login-action@v2 |
| 24 | + - name: 🚧️ Make release |
| 25 | + uses: goreleaser/goreleaser-action@v4 |
| 26 | + if: startsWith(github.ref, 'refs/tags/') |
| 27 | + env: |
| 28 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
22 | 29 | with: |
23 | | - username: ${{ secrets.DOCKER_LOGIN }} |
24 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
| 30 | + version: latest |
| 31 | + args: release --clean |
| 32 | + |
| 33 | + - name: 🧪 Set up Docker Buildx |
| 34 | + uses: docker/setup-buildx-action@v2 |
25 | 35 |
|
26 | | - - uses: docker/login-action@v2 |
| 36 | + - name: 🔒 Log in to the Container registry |
| 37 | + uses: docker/login-action@v2 |
27 | 38 | with: |
28 | | - registry: ghcr.io |
29 | | - username: ${{ github.repository_owner }} |
| 39 | + registry: ${{ env.REGISTRY }} |
| 40 | + username: ${{ github.actor }} |
30 | 41 | password: ${{ secrets.GITHUB_TOKEN }} |
31 | 42 |
|
32 | | - - name: Prepare Env Vars |
33 | | - run: | |
34 | | - echo GHCR_USER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV |
35 | | -
|
36 | | - # Publish a new release from git tag. |
37 | | - - uses: goreleaser/goreleaser-action@v4.2.0 |
38 | | - if: startsWith(github.ref, 'refs/tags/') |
39 | | - with: |
40 | | - version: latest |
41 | | - args: release --rm-dist |
| 43 | + - name: 🏗️ Build container and push |
| 44 | + uses: docker/build-push-action@v4 |
42 | 45 | env: |
43 | | - DOCKERHUB_USER: ${{ secrets.DOCKER_LOGIN }} |
44 | | - GHCR_USER: ${{ env.GHCR_USER }} |
45 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + TAG: ${{ github.ref_name }} |
| 47 | + COMMIT: ${{ github.sha }} |
| 48 | + with: |
| 49 | + cache-from: type=gha |
| 50 | + cache-to: type=gha,mode=max |
| 51 | + platforms: linux/amd64,linux/arm64 |
| 52 | + push: true |
| 53 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ github.ref_name }} |
0 commit comments