|
1 | 1 | name: release |
2 | 2 | on: |
| 3 | + push: |
| 4 | + tags: ['v*'] # cuando semantic-release crea el tag |
3 | 5 | release: |
4 | | - types: [published] |
| 6 | + types: [published] # cuando el GitHub Release se publica |
5 | 7 |
|
6 | 8 | permissions: |
7 | 9 | contents: read |
8 | 10 | packages: write |
9 | 11 |
|
| 12 | +concurrency: |
| 13 | + group: release-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
10 | 16 | jobs: |
11 | 17 | ghcr: |
12 | | - if: startsWith(github.event.release.tag_name, 'v') |
13 | 18 | runs-on: ubuntu-latest |
| 19 | + env: |
| 20 | + # nombre de imagen SIEMPRE en minúsculas |
| 21 | + IMAGE: ghcr.io/${{ github.repository }} |
| 22 | + TAG: ${{ github.ref_type == 'tag' && github.ref_name || github.event.release.tag_name }} |
14 | 23 | steps: |
15 | 24 | - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Lowercase image name |
| 27 | + run: echo "IMAGE=${IMAGE,,}" >> "$GITHUB_ENV" |
| 28 | + |
| 29 | + - uses: docker/setup-qemu-action@v3 |
16 | 30 | - uses: docker/setup-buildx-action@v3 |
17 | 31 | - uses: docker/login-action@v3 |
18 | 32 | with: |
19 | 33 | registry: ghcr.io |
20 | 34 | username: ${{ github.actor }} |
21 | 35 | password: ${{ secrets.GITHUB_TOKEN }} |
22 | | - - name: Set env |
23 | | - run: | |
24 | | - echo "TAG=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" |
25 | | - echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" |
26 | | - - name: Build & push (amd64+arm64) |
27 | | - run: | |
28 | | - docker buildx build \ |
29 | | - --platform linux/amd64,linux/arm64 \ |
30 | | - -t "$IMAGE:$TAG" -t "$IMAGE:latest" \ |
31 | | - --push . |
| 36 | + |
| 37 | + - uses: docker/build-push-action@v6 |
| 38 | + with: |
| 39 | + context: . |
| 40 | + file: ./Dockerfile |
| 41 | + platforms: linux/amd64 |
| 42 | + push: true |
| 43 | + provenance: false |
| 44 | + tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ env.TAG }} |
0 commit comments