diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 236ed7c..c5b76db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,31 +1,44 @@ name: release on: + push: + tags: ['v*'] # cuando semantic-release crea el tag release: - types: [published] + types: [published] # cuando el GitHub Release se publica permissions: contents: read packages: write +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: true + jobs: ghcr: - if: startsWith(github.event.release.tag_name, 'v') runs-on: ubuntu-latest + env: + # nombre de imagen SIEMPRE en minĂºsculas + IMAGE: ghcr.io/${{ github.repository }} + TAG: ${{ github.ref_type == 'tag' && github.ref_name || github.event.release.tag_name }} steps: - uses: actions/checkout@v4 + + - name: Lowercase image name + run: echo "IMAGE=${IMAGE,,}" >> "$GITHUB_ENV" + + - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set env - run: | - echo "TAG=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" - echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" - - name: Build & push (amd64+arm64) - run: | - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - -t "$IMAGE:$TAG" -t "$IMAGE:latest" \ - --push . + + - uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + provenance: false + tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ env.TAG }}