Skip to content

Commit

Permalink
Merge pull request #11 from peacock0803sz/docker-tag
Browse files Browse the repository at this point in the history
👍 Add tags to docker images
  • Loading branch information
lambdalisue committed Aug 18, 2023
2 parents 3c3e23c + 95888e5 commit c2aaceb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
denops_version:
description: Denops version
required: false
default: "main"
default: "v5.0.0" # or "main"

jobs:
build:
Expand All @@ -26,10 +26,26 @@ jobs:
id: vars
run: |
if [[ -z "${{ github.event.inputs.denops_version }}" ]]; then
echo '::set-output name=DENOPS_VERSION::main'
echo '::set-output name=DENOPS_VERSION::v5.0.0'
else
echo '::set-output name=DENOPS_VERSION::${{ github.event.inputs.denops_version }}'
fi
shell: bash
- run: make DENOPS_VERSION=${{ steps.vars.outputs.DENOPS_VERSION }} build
- run: make DENOPS_VERSION=${{ steps.vars.outputs.DENOPS_VERSION }} push

- name: Build and Push to ghcr.io
env:
DENOPS_VERSION: ${{ steps.vars.outputs.DENOPS_VERSION }}
shell: bash
run: |
make DENOPS_VERSION=$DENOPS_VERSION build
if [[ $DENOPS_VERSION == v* ]]; then
# Full version string
make DOCKER_TAG=$DENOPS_VERSION push
# vX.Y.Z -> vX.Y (major and minor)
export DOCKER_TAG_MINOR=$(echo $DENOPS_VERSION | sed -r 's/(v[0-9]+)(\.[0-9]+)(\.[0-9]+)/\1\2/')
make DOCKER_TAG=$DOCKER_TAG_MINOR push
# vX.Y.Z -> vX (major only)
export DOCKER_TAG_MAJOR=$(echo $DENOPS_VERSION | sed -r 's/(v[0-9]+)(\.[0-9]+)(\.[0-9]+)/\1/')
make DOCKER_TAG=$DOCKER_TAG_MAJOR push
fi
make DOCKER_TAG=latest push
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
DENOPS_VERSION := main
DOCKER_TAG := latest
DOCKER_REGISTRY := ghcr.io/vim-denops

.DEFAULT_GOAL := help

Expand All @@ -12,35 +14,33 @@ build: build-vim build-neovim ## Build
build-vim: FORCE ## Build (Vim)
docker buildx build ${BUILD_ARGS} \
--load \
--cache-from=ghcr.io/vim-denops/vim/cache \
--cache-from=ghcr.io/vim-denops/vim \
--cache-to=type=registry,ref=ghcr.io/vim-denops/vim/cache,mode=max \
--cache-from=${DOCKER_REGISTRY}/vim/cache \
--cache-from=${DOCKER_REGISTRY}/vim \
--cache-to=type=registry,ref=${DOCKER_REGISTRY}/vim/cache,mode=max \
--build-arg DENOPS_VERSION=${DENOPS_VERSION} \
-t ghcr.io/vim-denops/vim:${DENOPS_VERSION} \
-t ghcr.io/vim-denops/vim \
-t denops-dockerfile/vim \
-f Dockerfile.vim \
.

build-neovim: FORCE ## Build (Neovim)
docker buildx build ${BUILD_ARGS} \
--load \
--cache-from=ghcr.io/vim-denops/neovim/cache \
--cache-from=ghcr.io/vim-denops/neovim \
--cache-to=type=registry,ref=ghcr.io/vim-denops/neovim/cache,mode=max \
--cache-from=${DOCKER_REGISTRY}/neovim/cache \
--cache-from=${DOCKER_REGISTRY}/neovim \
--cache-to=type=registry,ref=${DOCKER_REGISTRY}/neovim/cache,mode=max \
--build-arg DENOPS_VERSION=${DENOPS_VERSION} \
-t ghcr.io/vim-denops/neovim:${DENOPS_VERSION} \
-t ghcr.io/vim-denops/neovim \
-t denops-dockerfile/neovim \
-f Dockerfile.neovim \
.

push: push-vim push-neovim ## Push

push-vim: FORCE ## Push (Vim)
docker push ghcr.io/vim-denops/vim:${DENOPS_VERSION}
docker push ghcr.io/vim-denops/vim
docker tag denops-dockerfile/vim ${DOCKER_REGISTRY}/vim:${DOCKER_TAG}
docker push ${DOCKER_REGISTRY}/vim:${DOCKER_TAG}

push-neovim: FORCE ## Push (Neovim)
docker push ghcr.io/vim-denops/neovim:${DENOPS_VERSION}
docker push ghcr.io/vim-denops/neovim
docker tag denops-dockerfile/neovim ${DOCKER_REGISTRY}/neovim:${DOCKER_TAG}
docker push ${DOCKER_REGISTRY}/neovim:${DOCKER_TAG}

FORCE:

0 comments on commit c2aaceb

Please sign in to comment.