127 lines
4.3 KiB
YAML
127 lines
4.3 KiB
YAML
name: release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Version ohne v (muss olares/Chart.yaml entsprechen)"
|
|
required: true
|
|
default: "26.11.1"
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
GITEA_API: https://git.aimighty.olares.de/api/v1
|
|
REGISTRY: git.aimighty.olares.de/aimighty
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Version prüfen
|
|
env:
|
|
V: ${{ inputs.version }}
|
|
run: |
|
|
CHART=$(awk '/^version:/{print $2}' olares/Chart.yaml | tr -d '"')
|
|
[ "$V" = "$CHART" ] || { echo "::error::Version $V != Chart.yaml $CHART"; exit 1; }
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
- run: npm ci
|
|
- run: npm run typecheck
|
|
- run: npm run build
|
|
|
|
- name: install helm
|
|
run: |
|
|
for url in \
|
|
"https://git.aimighty.olares.de/aimighty/ci-tools/releases/download/helm-3.16.2/helm-v3.16.2-linux-amd64.tar.gz" \
|
|
"https://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz"; do
|
|
if curl -fsSL --retry 3 --retry-all-errors --max-time 180 -o /tmp/helm.tgz "$url" \
|
|
&& tar -tzf /tmp/helm.tgz >/dev/null 2>&1; then break; fi
|
|
done
|
|
tar -C /tmp -xzf /tmp/helm.tgz
|
|
install -m 0755 /tmp/linux-amd64/helm /usr/local/bin/helm
|
|
helm version --short
|
|
|
|
- name: Chart prüfen und packen
|
|
env:
|
|
V: ${{ inputs.version }}
|
|
run: |
|
|
helm lint olares -f olares/values-olares-stub.yaml
|
|
mkdir -p dist
|
|
helm package olares -d dist
|
|
test -f "dist/courier-$V.tgz"
|
|
|
|
- name: Docker-Daemon des Runners finden (dind am Bridge-Gateway)
|
|
run: |
|
|
read -r _ dest gw _ < <(awk '$2=="00000000" {print; exit}' /proc/net/route)
|
|
GW="$(printf "%d.%d.%d.%d" 0x${gw:6:2} 0x${gw:4:2} 0x${gw:2:2} 0x${gw:0:2})"
|
|
ok=0
|
|
for KANDIDAT in "$GW" "172.17.0.1"; do
|
|
[ -n "$KANDIDAT" ] || continue
|
|
if DOCKER_HOST="tcp://$KANDIDAT:2375" docker version >/dev/null 2>&1; then
|
|
echo "DOCKER_HOST=tcp://$KANDIDAT:2375" >> "$GITHUB_ENV"
|
|
ok=1
|
|
break
|
|
fi
|
|
done
|
|
[ "$ok" = "1" ] || { echo "::error::kein Docker-Daemon gefunden"; exit 1; }
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.aimighty.olares.de
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build & push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
${{ env.REGISTRY }}/courier:${{ inputs.version }}
|
|
${{ env.REGISTRY }}/courier:latest
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: chart
|
|
path: dist/courier-${{ inputs.version }}.tgz
|
|
|
|
release:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
V: ${{ inputs.version }}
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: chart
|
|
path: dist
|
|
|
|
- name: Tag und Release anlegen
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.MARKT_TOKEN }}
|
|
run: |
|
|
NOTES="courier $V — Image ${REGISTRY}/courier:$V, Chart im Anhang."
|
|
BODY=$(python3 -c 'import json,sys; print(json.dumps({"tag_name":"v"+sys.argv[1],"target_commitish":sys.argv[2],"name":"v"+sys.argv[1],"body":sys.argv[3]}))' "$V" "${{ github.sha }}" "$NOTES")
|
|
RID=$(curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" \
|
|
"$GITEA_API/repos/$GITHUB_REPOSITORY/releases" -d "$BODY" \
|
|
| python3 -c "import sys,json; print(json.load(sys.stdin).get('id') or '')")
|
|
[ -n "$RID" ] || { echo "Release-Anlage fehlgeschlagen"; exit 1; }
|
|
curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@dist/courier-$V.tgz" \
|
|
"$GITEA_API/repos/$GITHUB_REPOSITORY/releases/$RID/assets?name=courier-$V.tgz" >/dev/null
|
|
echo "### v$V angelegt" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
|