Skip to content

Commit 295598d

Browse files
committed
Migration to GitHub Actions and image namespace update
1 parent 8cbb0c3 commit 295598d

10 files changed

+164
-135
lines changed

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
3+
updates:
4+
5+
- package-ecosystem: 'github-actions'
6+
directory: '/'
7+
schedule:
8+
interval: 'daily'

.github/workflows/ci.yml

-25
This file was deleted.

.github/workflows/main.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: 'Main'
2+
3+
on:
4+
push:
5+
tags: ['*']
6+
branches: ['*']
7+
pull_request:
8+
branches: ['*']
9+
workflow_dispatch:
10+
11+
jobs:
12+
13+
build:
14+
name: 'Build ${{ matrix.arch }} image'
15+
runs-on: 'ubuntu-latest'
16+
permissions:
17+
contents: 'read'
18+
strategy:
19+
matrix:
20+
arch: ['native', 'amd64', 'arm64v8', 'arm32v7']
21+
steps:
22+
- name: 'Checkout project'
23+
uses: 'actions/checkout@v3'
24+
- name: 'Register binfmt entries'
25+
if: "matrix.arch != 'native'"
26+
run: |
27+
make binfmt-register
28+
- name: 'Build and save image'
29+
run: |
30+
make IMAGE_BUILD_OPTS="--pull" "build-${{ matrix.arch }}-image" "save-${{ matrix.arch }}-image"
31+
- name: 'Upload artifacts'
32+
if: "startsWith(github.ref, 'refs/tags/v')"
33+
uses: 'actions/upload-artifact@v3'
34+
with:
35+
name: 'dist-${{ matrix.arch }}'
36+
path: './dist/'
37+
retention-days: 1
38+
39+
push:
40+
name: 'Push ${{ matrix.arch }} image'
41+
if: "startsWith(github.ref, 'refs/tags/v')"
42+
needs: ['build']
43+
runs-on: 'ubuntu-latest'
44+
permissions:
45+
contents: 'read'
46+
strategy:
47+
matrix:
48+
arch: ['amd64', 'arm64v8', 'arm32v7']
49+
steps:
50+
- name: 'Checkout project'
51+
uses: 'actions/checkout@v3'
52+
- name: 'Download artifacts'
53+
uses: 'actions/download-artifact@v3'
54+
with:
55+
name: 'dist-${{ matrix.arch }}'
56+
path: './dist/'
57+
- name: 'Login to Docker Hub'
58+
uses: 'docker/login-action@v1'
59+
with:
60+
registry: 'docker.io'
61+
username: '${{ secrets.DOCKERHUB_USERNAME }}'
62+
password: '${{ secrets.DOCKERHUB_TOKEN }}'
63+
- name: 'Load and push image'
64+
run: |
65+
make "load-${{ matrix.arch }}-image" "push-${{ matrix.arch }}-image"
66+
67+
push-manifest:
68+
name: 'Push manifest'
69+
if: "startsWith(github.ref, 'refs/tags/v')"
70+
needs: ['push']
71+
runs-on: 'ubuntu-latest'
72+
permissions:
73+
contents: 'read'
74+
steps:
75+
- name: 'Checkout project'
76+
uses: 'actions/checkout@v3'
77+
- name: 'Login to Docker Hub'
78+
uses: 'docker/login-action@v1'
79+
with:
80+
registry: 'docker.io'
81+
username: '${{ secrets.DOCKERHUB_USERNAME }}'
82+
password: '${{ secrets.DOCKERHUB_TOKEN }}'
83+
- name: 'Push manifest'
84+
run: |
85+
make push-cross-manifest
86+
87+
release-github:
88+
name: 'Create GitHub release'
89+
if: "startsWith(github.ref, 'refs/tags/v')"
90+
needs: ['push-manifest']
91+
runs-on: 'ubuntu-latest'
92+
permissions:
93+
contents: 'write'
94+
steps:
95+
- name: 'Create release'
96+
run: |
97+
RELEASE_STATUS="$(curl -fs --proto '=https' --tlsv1.3 --globoff \
98+
--url "https://api.github.com/repos/${GITHUB_REPOSITORY:?}/releases/tags/${GITHUB_REF_NAME:?}" \
99+
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
100+
--header 'Accept: application/vnd.github.v3+json' \
101+
--header 'Content-Type: application/json' \
102+
--write-out '%{http_code}' --output /dev/null ||:)"
103+
if [ "${RELEASE_STATUS:?}" = '200' ]; then exit 0; fi
104+
RELEASE_ID="$(curl -fsS --proto '=https' --tlsv1.3 --globoff \
105+
--url "https://api.github.com/repos/${GITHUB_REPOSITORY:?}/releases" \
106+
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
107+
--header 'Accept: application/vnd.github.v3+json' \
108+
--header 'Content-Type: application/json' \
109+
--data "$(jq -rn --arg tag "${GITHUB_REF_NAME:?}" '{"name": $tag, "tag_name": $tag, "generate_release_notes": true}')" | jq -r '.id')"
110+
if [ -z "${RELEASE_ID-}" ] || [ "${RELEASE_ID:?}" = 'null' ]; then exit 1; fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Rebuild latest release'
2+
3+
on:
4+
schedule:
5+
- cron: '20 04 * * 1'
6+
workflow_dispatch:
7+
8+
jobs:
9+
10+
trigger-rebuild:
11+
name: 'Trigger rebuild'
12+
runs-on: 'ubuntu-latest'
13+
permissions:
14+
contents: 'read'
15+
steps:
16+
- name: 'REST API call'
17+
run: |
18+
RELEASE_TAG="$(curl -fsS --proto '=https' --tlsv1.3 --globoff \
19+
--url 'https://api.github.com/repos/${{ github.repository }}/releases/latest' \
20+
--header 'Authorization: Bearer ${{ secrets.PERSONAL_GITHUB_TOKEN }}' \
21+
--header 'Accept: application/vnd.github.v3+json' \
22+
--header 'Content-Type: application/json' \
23+
| jq -rc '.tag_name')"
24+
if [ -n "${RELEASE_TAG-}" ] && [ "${RELEASE_TAG:?}" != 'null' ]; then
25+
curl -fsS --proto '=https' --tlsv1.3 --globoff \
26+
--url 'https://api.github.com/repos/${{ github.repository }}/actions/workflows/main.yml/dispatches' \
27+
--header 'Authorization: Bearer ${{ secrets.PERSONAL_GITHUB_TOKEN }}' \
28+
--header 'Accept: application/vnd.github.v3+json' \
29+
--header 'Content-Type: application/json' \
30+
--data "$(jq -rn --arg tag "${RELEASE_TAG:?}" '{"ref": $tag}')"
31+
else
32+
exit 1
33+
fi

.github/workflows/trigger-rebuild-latest-release.yml

-26
This file was deleted.

.gitlab-ci.yml

-74
This file was deleted.

Dockerfile.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ RUN mkisofs -no-emul-boot -iso-level 4 -eltorito-boot '[BOOT]/Boot-NoEmul.img' -
8282
##################################################
8383

8484
m4_ifdef([[CROSS_ARCH]], [[FROM docker.io/CROSS_ARCH/ubuntu:20.04]], [[FROM docker.io/ubuntu:20.04]]) AS base
85-
m4_ifdef([[CROSS_QEMU]], [[COPY --from=docker.io/hectormolinero/qemu-user-static:latest CROSS_QEMU CROSS_QEMU]])
85+
m4_ifdef([[CROSS_QEMU]], [[COPY --from=docker.io/hectorm/qemu-user-static:latest CROSS_QEMU CROSS_QEMU]])
8686

8787
# Install system packages
8888
RUN export DEBIAN_FRONTEND=noninteractive \

Makefile

+10-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ DISTDIR := ./dist
1111
DOCKERFILE_TEMPLATE := ./Dockerfile.m4
1212

1313
IMAGE_REGISTRY := docker.io
14-
IMAGE_NAMESPACE := hectormolinero
14+
IMAGE_NAMESPACE := hectorm
1515
IMAGE_PROJECT := qemu-win2000
1616
IMAGE_NAME := $(IMAGE_REGISTRY)/$(IMAGE_NAMESPACE)/$(IMAGE_PROJECT)
17-
IMAGE_VERSION := $(shell '$(GIT)' describe --abbrev=0 2>/dev/null || printf 'v0')
17+
IMAGE_GIT_TAG := $(shell '$(GIT)' tag -l --contains HEAD 2>/dev/null)
18+
IMAGE_GIT_SHA := $(shell '$(GIT)' rev-parse HEAD 2>/dev/null)
19+
IMAGE_VERSION := $(if $(IMAGE_GIT_TAG),$(IMAGE_GIT_TAG),$(if $(IMAGE_GIT_SHA),$(IMAGE_GIT_SHA),nil))
1820

1921
IMAGE_BUILD_OPTS :=
2022

@@ -107,7 +109,7 @@ $(IMAGE_ARM32V7_DOCKERFILE): $(DOCKERFILE_TEMPLATE)
107109
##################################################
108110

109111
define save_image
110-
'$(DOCKER)' save '$(1)' | zstd -T0 -19 > '$(2)'
112+
'$(DOCKER)' save '$(1)' | zstd -T0 > '$(2)'
111113
endef
112114

113115
.PHONY: save-native-image
@@ -220,20 +222,21 @@ push-cross-manifest:
220222

221223
.PHONY: binfmt-register
222224
binfmt-register:
223-
'$(DOCKER)' run --rm --privileged docker.io/hectormolinero/qemu-user-static:latest --reset
225+
'$(DOCKER)' run --rm --privileged docker.io/hectorm/qemu-user-static:latest --reset
224226

225227
##################################################
226228
## "version" target
227229
##################################################
228230

229231
.PHONY: version
230232
version:
231-
@if printf '%s' '$(IMAGE_VERSION)' | grep -q '^v[0-9]\{1,\}$$'; then \
232-
NEW_IMAGE_VERSION=$$(awk -v 'v=$(IMAGE_VERSION)' 'BEGIN {printf "v%.0f", substr(v,2)+1}'); \
233+
@LATEST_IMAGE_VERSION=$$('$(GIT)' describe --abbrev=0 2>/dev/null || printf 'v0'); \
234+
if printf '%s' "$${LATEST_IMAGE_VERSION:?}" | grep -q '^v[0-9]\{1,\}$$'; then \
235+
NEW_IMAGE_VERSION=$$(awk -v v="$${LATEST_IMAGE_VERSION:?}" 'BEGIN {printf("v%.0f", substr(v,2)+1)}'); \
233236
'$(GIT)' commit --allow-empty -m "$${NEW_IMAGE_VERSION:?}"; \
234237
'$(GIT)' tag -a "$${NEW_IMAGE_VERSION:?}" -m "$${NEW_IMAGE_VERSION:?}"; \
235238
else \
236-
>&2 printf 'Malformed version string: %s\n' '$(IMAGE_VERSION)'; \
239+
>&2 printf 'Malformed version string: %s\n' '$${LATEST_IMAGE_VERSION:?}'; \
237240
exit 1; \
238241
fi
239242

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ docker run --detach \
1212
--publish 127.0.0.1:3389:3389/tcp \
1313
--publish 127.0.0.1:5900:5900/tcp \
1414
--publish 127.0.0.1:6080:6080/tcp \
15-
docker.io/hectormolinero/qemu-win2000:latest
15+
docker.io/hectorm/qemu-win2000:latest
1616
```
1717

1818
The instance can be accessed from:

run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export LC_ALL=C
66
DOCKER=$(command -v docker 2>/dev/null)
77

88
IMAGE_REGISTRY=docker.io
9-
IMAGE_NAMESPACE=hectormolinero
9+
IMAGE_NAMESPACE=hectorm
1010
IMAGE_PROJECT=qemu-win2000
1111
IMAGE_TAG=latest
1212
IMAGE_NAME=${IMAGE_REGISTRY:?}/${IMAGE_NAMESPACE:?}/${IMAGE_PROJECT:?}:${IMAGE_TAG:?}

0 commit comments

Comments
 (0)