Skip to content

Commit 0e568e3

Browse files
committed
Adds GH workflows for maintenance releases
The problem for now is that the commit after dependency updates isn't pulled by futher steps. It's on the main branch though. Closes #46 by using buildah & qemu. Closes #61 by also pushing to ghcr.io
1 parent c0cf397 commit 0e568e3

File tree

14 files changed

+257
-129
lines changed

14 files changed

+257
-129
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
10+
...
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Build & publish deck-chores
2+
on:
3+
push:
4+
tags: ["*"]
5+
workflow_call:
6+
inputs:
7+
ref:
8+
required: false
9+
type: string
10+
secrets:
11+
DOCKER_AUTH_TOKEN:
12+
required: true
13+
PYPI_AUTH_TOKEN:
14+
required: true
15+
16+
jobs:
17+
version:
18+
outputs:
19+
version: ${{ steps.echo-version.outputs.version }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
ref: ${{ inputs.ref || github.ref }}
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.9
28+
- uses: abatilo/[email protected]
29+
30+
- id: echo-version
31+
run: echo "::set-ouput name=version::$(poetry version --short)"
32+
33+
- if: ${{ github.event_name == 'push' }}
34+
run: "[ ${{ steps.echo-version.outputs.version }} == ${{ github.ref }} ]"
35+
36+
37+
cheeseshop:
38+
name: Build & publish to the cheeseshop
39+
needs: [version]
40+
runs-on: ubuntu-latest
41+
steps:
42+
43+
- uses: actions/checkout@v2
44+
with:
45+
ref: ${{ inputs.ref || github.ref }}
46+
- uses: actions/setup-python@v2
47+
with:
48+
python-version: 3.9
49+
- uses: abatilo/[email protected]
50+
51+
- run: poetry build
52+
- run: poetry publish --username __token__ --password ${{ secrets.PYPI_AUTH_TOKEN }}
53+
54+
container-image:
55+
name: Build & push multi-architecture image
56+
needs: [version]
57+
env:
58+
IMAGE_NAME: deck-chores
59+
DOCKER_IO_USER: funkyfuture
60+
VERSION: ${{ needs.version.outputs.version }}
61+
runs-on: ubuntu-latest
62+
steps:
63+
64+
- uses: redhat-actions/podman-login@v1
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.actor }}
68+
password: ${{ github.token }}
69+
- uses: redhat-actions/podman-login@v1
70+
with:
71+
registry: docker.io
72+
username: ${{ env.DOCKER_IO_USER }}
73+
password: ${{ secrets.DOCKER_AUTH_TOKEN }}
74+
75+
- uses: actions/checkout@v2
76+
with:
77+
ref: ${{ inputs.ref || github.ref }}
78+
79+
- run: >
80+
echo "PRERELEASE=${{ (
81+
contains('a', env.VERSION) || contains('b', env.VERSION)
82+
|| contains('rc', env.VERSION) || contains('pre', env.VERSION)
83+
) }}" >> $GITHUB_ENV
84+
- name: echo version related variables
85+
run: |
86+
echo 'VERSION: ${{ env.VERSION }}'
87+
echo 'PRERELEASE: ${{ env.PRERELEASE }}'
88+
- id: docker-metadata
89+
uses: docker/metadata-action@v3
90+
with:
91+
images: ${{ env.IMAGE_NAME }}
92+
flavor: latest=false
93+
labels: |
94+
org.opencontainers.image.documentation=https://deck-chores.readthedocs.org/
95+
org.opencontainers.image.url=https://deck-chores.readthedocs.org/
96+
tags: |
97+
type=sha,prefix=src-commit-
98+
type=pep440,pattern={{version}},value=${{ env.VERSION }}
99+
type=pep440,pattern={{major}},value=${{ env.VERSION }},enable=${{ env.PRERELEASE == 'false' }}
100+
type=pep440,pattern={{major}}.{{minor}},value=${{ env.VERSION }},enable=${{ env.PRERELEASE == 'false' }}
101+
- name: prepare push tag value
102+
id: push-tags-value
103+
run: echo "::set-output name=tags::${{ steps.docker-metadata.outputs.tags }}" | tr "\n" " " | sed "s/${{ env.IMAGE_NAME }}://g"
104+
105+
- name: install dependency for multi-platform builds
106+
run: |
107+
sudo apt update
108+
sudo apt install -y qemu-user-static
109+
- id: build-image
110+
uses: redhat-actions/buildah-build@v2
111+
with:
112+
containerfiles: |
113+
./Dockerfile
114+
image: ${{ env.IMAGE_NAME }}
115+
labels: ${{ steps.docker-metadata.outputs.labels }}
116+
platforms: linux/amd64,linux/arm,linux/arm64
117+
tags: ${{ steps.docker-metadata.outputs.tags }}
118+
119+
- name: echo build outputs
120+
run: |
121+
echo "Image: ${{ steps.build-image.outputs.image }}"
122+
echo "Tags: ${{ steps.build-image.outputs.tags }}"
123+
echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}"
124+
- name: echo created images
125+
run: buildah images | grep '${{ env.IMAGE_NAME }}'
126+
- name: echo image metadata
127+
run: buildah inspect ${{ steps.build-image.outputs.image-with-tag }}
128+
129+
- name: push to ghcr.io
130+
uses: redhat-actions/push-to-registry@v2
131+
with:
132+
registry: ghcr.io/${{ github.actor }}
133+
image: ${{ steps.build-image.outputs.image }}
134+
tags: ${{ steps.push-tags-value.outputs.tags }}
135+
136+
- name: push to docker.io
137+
uses: redhat-actions/push-to-registry@v2
138+
with:
139+
registry: docker.io/${{ env.DOCKER_IO_USER }}
140+
image: ${{ steps.build-image.outputs.image }}
141+
tags: ${{ steps.push-tags-value.outputs.tags }}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Update dependencies & create a maintence release
2+
on:
3+
schedule:
4+
- cron: "35 10 12 * *"
5+
workflow_dispatch:
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-python@v2
13+
with:
14+
python-version: 3.9
15+
- uses: abatilo/[email protected]
16+
17+
- run: poetry update --lock
18+
19+
- id: commit-and-push
20+
uses: stefanzweifel/git-auto-commit-action@v4
21+
with:
22+
commit_message: Updates dependencies
23+
24+
- if: ${{ steps.commit-and-push.outputs.changes_detected == false }}
25+
run: gh run cancel ${{ github.run_id }} && tail -f /dev/null
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}
28+
29+
run-tests:
30+
needs: [update]
31+
uses: funkyfuture/deck-chores/.github/workflows/quality-checks.yml@main
32+
with:
33+
ref: main
34+
35+
bump-version:
36+
needs: [run-tests]
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
with:
41+
ref: main
42+
- uses: actions/setup-python@v2
43+
with:
44+
python-version: 3.9
45+
- uses: abatilo/[email protected]
46+
47+
- id: bump
48+
run: |
49+
poetry version patch
50+
echo "set-output:: name=version::$(poetry version --short)"
51+
52+
- uses: stefanzweifel/git-auto-commit-action@v4
53+
with:
54+
commit_message: >
55+
Bumps version to ${{ steps.bump.outputs.version }} (maintenance release)
56+
tagging_message: ${{ steps.bump.outputs.version }}
57+
58+
build-and-publish:
59+
needs: [bump-version]
60+
uses: funkyfuture/deck-chores/.github/workflows/build-and-publish.yml@main
61+
with:
62+
ref: main
63+
secrets:
64+
DOCKER_AUTH_TOKEN: ${{ secrets.DOCKER_AUTH_TOKEN }}
65+
PYPI_AUTH_TOKEN: ${{ secrets.PYPI_AUTH_TOKEN }}

.github/workflows/quality-checks.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
---
22

33
name: quality-checks
4+
45
on:
56
pull_request:
67
push:
7-
branches:
8-
- main
8+
branches:
9+
- main
10+
workflow_call:
11+
inputs:
12+
ref:
13+
required: false
14+
type: string
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.sha }}
18+
cancel-in-progress: true
19+
920
jobs:
1021
python-tests:
1122
runs-on: ubuntu-latest
@@ -18,6 +29,8 @@ jobs:
1829
- target: doclinks
1930
steps:
2031
- uses: actions/checkout@v2
32+
with:
33+
ref: ${{ inputs.ref || github.sha }}
2134
- uses: actions/setup-python@v2
2235
with:
2336
python-version: 3.9
@@ -28,13 +41,21 @@ jobs:
2841
restore-keys: |
2942
${{ runner.os }}-pip-
3043
- run: python -m pip install --upgrade pip setuptools wheel
31-
- uses: abatilo/[email protected].0
44+
- uses: abatilo/[email protected].4
3245
- run: poetry install -v
3346
- run: poetry run make ${{ matrix.target }}
3447

35-
docker-build-test:
48+
image-build-test:
3649
runs-on: ubuntu-latest
3750
steps:
38-
- uses: docker/build-push-action@v2
51+
- uses: actions/checkout@v2
52+
with:
53+
ref: ${{ inputs.ref || github.sha }}
54+
- uses: redhat-actions/buildah-build@v2
55+
with:
56+
containerfiles: |
57+
./Dockerfile
58+
image: ${{ github.repository }}
59+
tags: test-build-${{ github.sha }}
3960

4061
...

Dockerfile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
FROM python:3.9-alpine
1+
FROM docker.io/python:3.9-alpine
22

33
MAINTAINER Frank Sachsenheim <[email protected]>
44

5-
ARG VERSION
6-
ARG SOURCE_COMMIT
7-
ARG BUILD_DATE
8-
9-
LABEL org.opencontainers.image.created=$BUILD_DATE \
10-
org.opencontainers.image.description="Job scheduler for Docker containers, configured via labels." \
11-
org.opencontainers.image.documentation="https://deck-chores.readthedocs.org/" \
12-
org.opencontainers.image.revision=$SOURCE_COMMIT \
13-
org.opencontainers.image.source="https://github.com/funkyfuture/deck-chores" \
14-
org.opencontainers.image.title="deck-chores" \
15-
org.opencontainers.image.version=$VERSION
16-
175
CMD ["deck-chores"]
186
ENV PYTHONOPTIMIZE=1
197
# could be 2 with Cerberus 2

Dockerfile-dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9-alpine
1+
FROM docker.io/python:3.9-alpine
22

33
CMD ["deck-chores"]
44
LABEL org.label-schema.name="deck-chores"

Makefile

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
.DEFAULT_GOAL := build-dev
22

33
REPO_NAME = funkyfuture/deck-chores
4-
VERSION = $(shell grep -oP "^version = \K.+" pyproject.toml | tr -d '"')
4+
VERSION = $(shell poetry version --short)
55
IMAGE_NAME = $(REPO_NAME):$(VERSION)
6-
GIT_SHA1 = $(shell git rev-parse HEAD)
7-
8-
export IMAGE_NAME
9-
export GIT_SHA1
106

117
define PRINT_HELP_PYSCRIPT
128
import re, sys
@@ -21,11 +17,11 @@ export PRINT_HELP_PYSCRIPT
2117

2218
.PHONY: black
2319
black: ## code-formatting with black
24-
poetry run black deck_chores tests
20+
poetry run black deck_chores tests
2521

2622
.PHONY: build
2723
build: ## builds the Docker image
28-
hooks/build
24+
docker build --tag $(IMAGE_NAME) .
2925

3026
.PHONY: build-dev
3127
build-dev: ## builds the Docker image for debugging
@@ -76,11 +72,6 @@ help: ## print make targets help
7672
lint: black ## check style with flake8
7773
poetry run flake8 --max-complexity=10 --max-line-length=89 deck_chores tests
7874

79-
.PHONY: maintenance-release
80-
maintenance-release: ## publish a maintenance with updated dependencies
81-
bash ./maintenance-updates.sh
82-
$(MAKE) release
83-
8475
.PHONY: mypy
8576
mypy: ## check types with mypy
8677
poetry run mypy --ignore-missing-imports deck_chores
@@ -94,19 +85,8 @@ test: lint mypy pytest ## run all tests
9485

9586
.PHONY: release
9687
release: test doclinks build ## release the current version on github, the PyPI and the Docker hub
97-
git tag -f $(VERSION)
98-
git push origin main
99-
git push -f origin $(VERSION)
100-
poetry publish --build
101-
$(MAKE) release-multiimage
102-
103-
.PHONY: release-arm
104-
release-arm: ## release the arm build on the Docker hub
105-
hooks/release-arm $(IMAGE_NAME) $(GIT_SHA1)
106-
107-
.PHONY: release-multiimage
108-
release-multiimage: release-arm ## release the multi-arch manifest on the Docker hub
109-
hooks/release-multiimage $(REPO_NAME) $(VERSION)
88+
git tag $(VERSION)
89+
git push origin refs/tags/$(VERSION)
11090

11191
.PHONY: run
11292
run: build ## runs deck-chores in a temporary container

README.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ deck-chores
1313
**A job scheduler for Docker containers, configured via container labels.**
1414

1515
* Documentation: https://deck-chores.readthedocs.io
16-
* Image repository: https://hub.docker.com/r/funkyfuture/deck-chores
16+
* Image repositories:
17+
* https://github.com/funkyfuture/deck-chores/pkgs/container/deck-chores
18+
* https://hub.docker.com/r/funkyfuture/deck-chores
1719
* Code repository: https://github.com/funkyfuture/deck-chores
1820
* Issue tracker: https://github.com/funkyfuture/deck-chores/issues
1921
* Free software: ISC license
@@ -27,8 +29,7 @@ Features
2729
- use date, interval and cron-like triggers
2830
- set a maximum of simultaneously running instances per job
2931
- restrict job scheduling to one container per service
30-
- multi-architecture image supports ``amd64``, ``arm64`` and ``armv7l`` platforms, no emulator
31-
involved
32+
- multi-architecture image supports ``amd64``, ``arm64`` and ``arm`` platforms
3233

3334

3435
Example

0 commit comments

Comments
 (0)