0.11.0 #100
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Publish | |
| # Builds the server container (build/Dockerfile) and pushes it to GHCR so it can | |
| # be pulled by self-hosted deployments and the Unraid Community Applications app | |
| # (ghcr.io/stemdeckapp/stemdeck). The image keeps the default Linux x86_64 torch | |
| # wheel, which is the CUDA build -- so the same image runs on CPU by default and | |
| # uses the GPU automatically when started with `--runtime=nvidia` (see the | |
| # Unraid template in templates/unraid/). | |
| on: | |
| # Every merge to main publishes a rolling :edge image. The version is derived | |
| # from git (hatch-vcs style); :edge never clobbers :latest. | |
| push: | |
| branches: [main] | |
| release: | |
| # published: the reliable trigger -- fires whenever a release (draft or not, | |
| # prerelease or not) is published. Confirmed empirically: publishing a draft | |
| # prerelease fires `published` but NOT `prereleased` (the v0.8.0-alpha.7 | |
| # release never got its version tag pushed until this was added back). | |
| # released: an already-published prerelease is promoted to a full/Latest | |
| # release via the "Release label" edit -- pushes :latest for that case too. | |
| types: [published, released] | |
| # Same as a main push but on demand, from any ref. `version` lets a specific | |
| # tag be (re)pushed by hand -- e.g. to recover from a missed release trigger | |
| # without re-touching the release (which would re-run the OS build workflows). | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version tag to push (e.g. 0.8.0-alpha.7). Leave blank for a git-derived :edge-only push." | |
| required: false | |
| default: "" | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| IMAGE: ghcr.io/${{ github.repository_owner }}/stemdeck | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| # Full history + tags so git describe can derive a version on manual runs. | |
| fetch-depth: 0 | |
| # Derive the version fed to the Dockerfile's VERSION build-arg (consumed as | |
| # SETUPTOOLS_SCM_PRETEND_VERSION, so it MUST be PEP 440-valid). On a | |
| # release, use the tag. Otherwise derive from git: `git describe --long` | |
| # yields `<tag>-<N>-g<sha>`, which is NOT PEP 440 -- rewrite the trailing | |
| # `-N-gSHA` into a `+N.gSHA` local segment (e.g. 0.8.0-alpha.5+3.gce86e8a). | |
| - name: resolve version | |
| id: ver | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| v="${{ github.event.release.tag_name }}" | |
| elif [ -n "${{ github.event.inputs.version }}" ]; then | |
| v="${{ github.event.inputs.version }}" | |
| else | |
| raw="$(git describe --tags --long 2>/dev/null || echo "0.0.0-0-g$(git rev-parse --short HEAD)")" | |
| v="$(printf '%s' "${raw#v}" | sed -E 's/-([0-9]+)-g([0-9a-f]+)$/+\1.g\2/')" | |
| fi | |
| echo "value=${v#v}" >> "$GITHUB_OUTPUT" | |
| - name: docker metadata (tags/labels) | |
| id: meta | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ${{ env.IMAGE }} | |
| tags: | | |
| type=raw,value=edge,enable=${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.version == '') }} | |
| type=raw,value=${{ steps.ver.outputs.value }},enable=${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.version != '') }} | |
| type=raw,value=latest,enable=${{ github.event_name == 'release' && (github.event.action == 'released' || (github.event.action == 'published' && !github.event.release.prerelease)) }} | |
| - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| - name: log in to GHCR | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: build and push | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 | |
| with: | |
| context: . | |
| file: build/Dockerfile | |
| # Unraid is x86_64; arm64 has no CUDA torch and is not a target. | |
| platforms: linux/amd64 | |
| push: true | |
| build-args: | | |
| VERSION=${{ steps.ver.outputs.value }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: false |