Skip to content

Commit

Permalink
chore(ci): add Makefile for Exctract and add release workflow (#19)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hbollon authored Sep 11, 2024
1 parent be44dbb commit 4059902
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions extract/Makefile
Original file line number Diff line number Diff line change
@@ -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 <target>"
@echo
@echo "Available targets:"
@grep --extended-regexp --no-filename '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s%s\n", $$1, $$2}'

0 comments on commit 4059902

Please sign in to comment.