From 4059902a604d660a5cf74c6eab37350034116110 Mon Sep 17 00:00:00 2001 From: Hugo Bollon Date: Wed, 11 Sep 2024 11:35:47 +0200 Subject: [PATCH] chore(ci): add Makefile for Exctract and add release workflow (#19) * chore(ci): add Makefile for Extract and add release workflow * chore: add default make target * ci(release): format tags to x.y.z-c2c.a --- .github/workflows/release.yml | 37 +++++++++++++++++++++++++++++++++++ extract/Makefile | 31 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 extract/Makefile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f2c6f70 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: GHCR Release CI + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+-c2c.[0-9]+" + +jobs: + tests: + name: Release new Docker Image in GHCR + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set current directory to Extract + run: cd extract + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.repository_owner}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: Build Docker images for GHCR + run: make build_ghcr + + - name: Push Docker images to GHCR + run: make push_ghcr diff --git a/extract/Makefile b/extract/Makefile new file mode 100644 index 0000000..6b95806 --- /dev/null +++ b/extract/Makefile @@ -0,0 +1,31 @@ +VERSION ?= $(shell git describe --always --tags) +DOCKER_TAG ?= latest + +export DOCKER_BUILDKIT=1 + +.DEFAULT_GOAL := help + +.PHONY: build_docker +build_docker: ## Build docker image + docker build --tag=camptocamp/asit-extract:$(VERSION) \ + --build-arg=VERSION=$(VERSION) . + docker tag camptocamp/asit-extract:$(VERSION) camptocamp/asit-extract:$(DOCKER_TAG) + +.PHONY: build_ghcr +build_ghcr: ## Build docker image tagged for GHCR + docker build --tag=ghcr.io/camptocamp/asit-extract:$(VERSION) \ + --build-arg=VERSION=$(VERSION) . + docker tag ghcr.io/camptocamp/asit-extract:$(VERSION) ghcr.io/camptocamp/asit-extract:$(DOCKER_TAG) + +.PHONY: push_ghcr +push_ghcr: ## Push docker image to GHCR + docker push ghcr.io/camptocamp/asit-extract:$(VERSION) + docker push ghcr.io/camptocamp/asit-extract:$(DOCKER_TAG) + +.PHONY: help +help: ## Display this help + @echo "Usage: make " + @echo + @echo "Available targets:" + @grep --extended-regexp --no-filename '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | sort | \ + awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s%s\n", $$1, $$2}'