From 2761a75a8d54087b7252e7a3e5f5b227215c2c42 Mon Sep 17 00:00:00 2001 From: Johannes Schnatterer Date: Wed, 25 Oct 2023 17:24:17 +0200 Subject: [PATCH] GH Action: Change logic for finding out latest release Not newest git tag, but latest release from GitHub. Matches the one installed in the docker image using "go install ..@latest" --- .github/workflows/docker-image.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8003486..aaf69c3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,14 +15,6 @@ jobs: steps: - name: Checkout image repo uses: actions/checkout@v3 - - name: Checkout upstream repo - uses: actions/checkout@v3 - with: - repository: mailhog/mailhog - token: ${{ secrets.GITHUB_TOKEN }} - path: upstream - # We're only interested in the tags, so check them out, too (not just a single commit) - fetch-depth: 0 - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -32,9 +24,8 @@ jobs: - name: Create tags id: create-tag run: | - # Find latest tag - cd upstream - VERSION="$(git describe --tags $(git rev-list --tags --max-count=1))" + # Find latest release (same as "go install github.com/mailhog/MailHog@latest" in Dockerfile) + VERSION="$( curl -s -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/mailhog/mailhog/releases/latest" | jq -r '.tag_name')" VERSION_DATE="$VERSION-$(date +'%Y-%m-%d')" GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/mailhog