okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Docker docs, compose defaults, scripts and the file test name the 0.2.7 image tags (0.2.7-cuda13 and the other flavors)df20d7784

main
4.3 KiB114 linesraw
1name: Docker images
2
3# Builds the Strata container images of one release from its engine packages and pushes them to ghcr.io.
4# Run by hand only (Actions tab -> Docker images -> Run workflow). Nothing starts it on its own.
5#
6# For each flavor the job downloads the engine package from the release and checks it against the signed update feed
7# (docker/fetch-engines.py: the feed's Ed25519 signature, the archive's SHA-256, the manifest hash, the package signature,
8# every file's hash), builds the image with docker/build.sh and, only when "push" is on, pushes
9#   ghcr.io/niko1221/strata:<version>-<flavor>   and   ghcr.io/niko1221/strata:latest-<flavor>
10# The first run with "push" off builds everything without publishing it (a dry run).
11
12on:
13  workflow_dispatch:
14    inputs:
15      release_tag:
16        description: 'Release tag whose engine packages go into the images (for example v0.2.7)'
17        required: true
18        type: string
19      flavors:
20        description: 'Flavors to build, comma separated (empty: every flavor the release has a package for)'
21        required: false
22        default: ''
23        type: string
24      push:
25        description: 'Push the images to ghcr.io (off: build only, nothing is published)'
26        required: true
27        default: false
28        type: boolean
29      latest:
30        description: 'Also move the latest-<flavor> tags (turn off for a pre-release or a test)'
31        required: true
32        default: true
33        type: boolean
34      source_ref:
35        description: 'Git ref of the Dockerfile and the Terminal sources (empty: the release tag)'
36        required: false
37        default: ''
38        type: string
39
40permissions:
41  contents: read
42
43env:
44  IMAGE: ghcr.io/niko1221/strata
45
46jobs:
47  plan:
48    runs-on: ubuntu-24.04
49    outputs:
50      flavors: ${{ steps.list.outputs.flavors }}
51    steps:
52      - uses: actions/checkout@v4
53        with:
54          ref: ${{ inputs.source_ref || inputs.release_tag }}
55      - name: Which flavors does the release have a package for
56        id: list
57        env:
58          WANT: ${{ inputs.flavors }}
59          TAG: ${{ inputs.release_tag }}
60        run: |
61          set -eu
62          args="--release-tag $TAG --list --skip-missing"
63          [ -n "$WANT" ] && args="$args --flavors $WANT"
64          python3 docker/fetch-engines.py $args > list.tsv
65          cat list.tsv
66          flavors=$(awk -F'\t' '$3 != "SKIP" {printf "%s\"%s\"", (n++ ? "," : ""), $1}' list.tsv)
67          [ -n "$flavors" ] || { echo "the release has no engine package for any requested flavor"; exit 1; }
68          echo "flavors=[$flavors]" >> "$GITHUB_OUTPUT"
69
70  image:
71    needs: plan
72    runs-on: ubuntu-24.04
73    timeout-minutes: 120
74    permissions:
75      contents: read
76      packages: write
77    strategy:
78      fail-fast: false
79      max-parallel: 3
80      matrix:
81        flavor: ${{ fromJSON(needs.plan.outputs.flavors) }}
82    steps:
83      - uses: actions/checkout@v4
84        with:
85          ref: ${{ inputs.source_ref || inputs.release_tag }}
86      - name: Free disk space (the runner has about 14 GB; a package plus its image needs about 10 GB)
87        run: |
88          sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL || true
89          docker system prune -af >/dev/null 2>&1 || true
90          df -h /
91      - name: Log in to ghcr.io
92        if: ${{ inputs.push }}
93        env:
94          REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95          REGISTRY_USER: ${{ github.actor }}
96        run: printf '%s' "$REGISTRY_TOKEN" | docker login ghcr.io -u "$REGISTRY_USER" --password-stdin
97      - name: Fetch, verify, build (and push when push is on)
98        env:
99          TAG: ${{ inputs.release_tag }}
100          FLAVOR: ${{ matrix.flavor }}
101          PUSH: ${{ inputs.push && '--push' || '' }}
102          LATEST: ${{ !inputs.latest && '--no-latest' || '' }}
103        run: |
104          docker/publish.sh --release-tag "$TAG" --flavors "$FLAVOR" --image "$IMAGE" $PUSH $LATEST
105      - name: Summary
106        if: ${{ always() }}
107        run: |
108          {
109            echo "### ${{ matrix.flavor }}"
110            echo "- release: ${{ inputs.release_tag }}, pushed: ${{ inputs.push }}"
111            echo "- image: \`$IMAGE:${INPUT_TAG#v}-${{ matrix.flavor }}\`"
112          } >> "$GITHUB_STEP_SUMMARY"
113        env:
114          INPUT_TAG: ${{ inputs.release_tag }}