diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2fb3891..4ee8950 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,20 +7,64 @@ on: jobs: release: - name: Docker runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fetch tags + run: git fetch --force --tags + - name: Setup QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 + id: buildx - - name: Check out code - uses: actions/checkout@v2 + - name: Login to container Registry + uses: docker/login-action@v2 + with: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + + - name: Prepare + id: prep + run: | + VERSION=sha-${GITHUB_SHA::8} + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF/refs\/tags\//} + fi + echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=VERSION::${VERSION} + + - name: Publish multi-arch Docker image + uses: docker/build-push-action@v4 + with: + push: true + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/arm64,linux/amd64 + tags: | + ghcr.io/${{ github.repository_owner }}/bankroach:${{ steps.prep.outputs.VERSION }} + ghcr.io/${{ github.repository_owner }}/bankroach:latest + labels: | + org.opencontainers.image.title=${{ github.event.repository.name }} + org.opencontainers.image.description=${{ github.event.repository.description }} + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.url=${{ github.event.repository.html_url }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} - - name: Release + - name: GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + version: latest + args: release env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: ./scripts/release.sh + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index 0d9fa19..0000000 --- a/scripts/release.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -e - -docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - -git fetch --all -tag=$(git describe --abbrev=0 --tags) -name="bankroach" -image="mmontes11/$name" -platform="linux/amd64,linux/arm64,linux/arm" - -echo "🏗 Building image '$image:$tag'..." -docker buildx create --name "$name" --use --append -docker buildx build --platform "$platform" -t "$image:$tag" -t "$image:latest" --push . -docker buildx imagetools inspect "$image:latest"