Skip to content

Commit

Permalink
Introduce release workflow (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
defanator authored Oct 14, 2024
1 parent 83c219e commit f9c2504
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: zont_api release

on:
workflow_dispatch:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install tox
run: pip install tox
- name: Run linters
run: make lint
- name: Run tests
run: make show-env test
- name: Build package
run: make build
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.tar.gz
dist/*.whl
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images
run: make images

12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ VERSION := $(shell git describe --tags --always --match='v[0-9]*' | cut -d '-' -
RELEASE := $(shell git describe --tags --always --match='v[0-9]*' --long | cut -d '-' -f 2)
BUILD := $(shell git describe --tags --long --always --dirty)-$(DATE)-$(GITHUB_RUN_ID)

IMAGE_TAG := zont_prom_exporter
IMAGE_PATH := defanator
IMAGE_REGISTRY := ghcr.io

define __VERSION_CONTENT__
"""
Dynamic version info
Expand Down Expand Up @@ -73,6 +77,14 @@ image: build ## Build container image with zont_prom_exporter
-t zont_prom_exporter:$(VERSION) \
$(TOPDIR)

images: build ## Build multi-arch container images with zont_prom_exporter
docker buildx build --push \
--platform linux/arm64,linux/amd64 \
-f $(TOPDIR)/examples/zont_prom_exporter/Dockerfile \
--build-arg ZONT_API_VERSION=$(VERSION) \
-t $(IMAGE_REGISTRY)/$(IMAGE_PATH)/$(IMAGE_TAG):$(VERSION) \
$(TOPDIR)

clean: ## Clean up
find $(TOPDIR)/ -type f -name "*.pyc" -delete
find $(TOPDIR)/ -type f -name "*.pyo" -delete
Expand Down

0 comments on commit f9c2504

Please sign in to comment.