diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 933ee10e..88b9f240 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,37 +9,45 @@ jobs: publish: name: Publish runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 20 + + permissions: + contents: write + packages: write steps: - - uses: actions/checkout@v3 + - name: ๐Ÿ“ฆ Checkout repository + uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-go@v4 - - - uses: docker/login-action@v2 + - name: ๐Ÿšง๏ธ Make release + uses: goreleaser/goreleaser-action@v4 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - username: ${{ secrets.DOCKER_LOGIN }} - password: ${{ secrets.DOCKER_PASSWORD }} + version: latest + args: release --clean + + - name: ๐Ÿงช Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - uses: docker/login-action@v2 + - name: ๐Ÿ”’ Log in to the Container registry + uses: docker/login-action@v2 with: - registry: ghcr.io - username: ${{ github.repository_owner }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Prepare Env Vars - run: | - echo GHCR_USER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - - # Publish a new release from git tag. - - uses: goreleaser/goreleaser-action@v4.2.0 - if: startsWith(github.ref, 'refs/tags/') - with: - version: latest - args: release --rm-dist + - name: ๐Ÿ—๏ธ Build container and push + uses: docker/build-push-action@v4 env: - DOCKERHUB_USER: ${{ secrets.DOCKER_LOGIN }} - GHCR_USER: ${{ env.GHCR_USER }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + COMMIT: ${{ github.sha }} + with: + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ github.ref_name }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 5d2a1401..d5bd6d76 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -19,14 +19,6 @@ builds: - arm - arm64 -dockers: - - image_templates: - - "{{ .Env.DOCKERHUB_USER }}/podsync:{{ .Tag }}" - - "{{ .Env.DOCKERHUB_USER }}/podsync:v{{ .Major }}.{{ .Minor }}" - - "{{ .Env.DOCKERHUB_USER }}/podsync:latest" - - "ghcr.io/{{ .Env.GHCR_USER }}/podsync:{{ .Tag }}" - - "ghcr.io/{{ .Env.GHCR_USER }}/podsync:latest" - archives: - replacements: darwin: Darwin