diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c7cd4a3c..733f33607 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,17 @@ on: # - "[0-9]+.[0-9]+.[0-9]+*" release: types: [published] + # Rolling `edge` image of master. + push: + branches: [master] + paths-ignore: + - "**.md" + - "docs/**" + +# Two quick merges must not race, or the older build could land on `edge` last. +concurrency: + group: build-${{ github.event_name == 'push' && 'edge' || github.ref }} + cancel-in-progress: ${{ github.event_name == 'push' }} permissions: contents: read @@ -27,7 +38,7 @@ jobs: env: TAG: ${{ github.event.release.tag_name }} run: | - if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+)?$ ]]; then + if [[ "$GITHUB_EVENT_NAME" == "push" || "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-alpha\.[0-9]+|-beta\.[0-9]+|-rc\.[0-9]+)?$ ]]; then echo "valid=true" >>"$GITHUB_OUTPUT" else echo "valid=false" >>"$GITHUB_OUTPUT" @@ -54,6 +65,9 @@ jobs: packages: write env: CACHE_IMAGE: ghcr.io/${{ github.repository_owner }}/romm-buildcache + # Edge reads the release cache but writes its own, so master layers never + # seed a release image. + CACHE_SCOPE: ${{ github.event_name == 'push' && 'edge' || 'release' }} steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -90,6 +104,8 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + type=raw,value=edge,enable=${{ github.event_name == 'push' }} + type=sha,prefix=edge-,enable=${{ github.event_name == 'push' }} labels: | org.opencontainers.image.version={{version}}-slim org.opencontainers.image.title="rommapp/romm" @@ -107,16 +123,23 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + type=raw,value=edge,enable=${{ github.event_name == 'push' }} + type=sha,prefix=edge-,enable=${{ github.event_name == 'push' }} labels: | org.opencontainers.image.version={{version}} org.opencontainers.image.title="rommapp/romm" org.opencontainers.image.description="RomM (ROM Manager) allows you to scan, enrich, and browse your game collection with a clean and responsive interface. With support for multiple platforms, various naming schemes and custom tags, RomM is a must-have for anyone who plays on emulators." org.opencontainers.image.licenses="AGPLv3" + # Edge builds carry the short commit (matching the `edge-` tag) so each + # one is identifiable and busts version-keyed caches. - name: Set version env: VERSION: ${{ steps.meta.outputs.version }} run: | + if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then + VERSION="${VERSION}-${GITHUB_SHA::7}" + fi sed -i "s//$VERSION/" backend/__version__.py - name: Build and push slim image by digest @@ -135,7 +158,9 @@ jobs: no-cache-filters: python-runtime,production-stage # Deliberately not seeded from the preview cache: those layers are # built from PR head content and must not reach a release image. - cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:release-${{ matrix.arch }} + cache-from: | + type=registry,ref=${{ env.CACHE_IMAGE }}:release-${{ matrix.arch }} + ${{ env.CACHE_SCOPE == 'edge' && format('type=registry,ref={0}:edge-{1}', env.CACHE_IMAGE, matrix.arch) || '' }} build-args: | SCREENSCRAPER_DEV_ID=${{ secrets.SCREENSCRAPER_DEV_ID }} SCREENSCRAPER_DEV_PASSWORD=${{ secrets.SCREENSCRAPER_DEV_PASSWORD }} @@ -153,8 +178,10 @@ jobs: target: full-image outputs: type=image,name=${{ env.DIGEST_IMAGE }},push-by-digest=true,name-canonical=true,push=true no-cache-filters: python-runtime,production-stage - cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}:release-${{ matrix.arch }} - cache-to: type=registry,ref=${{ env.CACHE_IMAGE }}:release-${{ matrix.arch }},mode=max + cache-from: | + type=registry,ref=${{ env.CACHE_IMAGE }}:release-${{ matrix.arch }} + ${{ env.CACHE_SCOPE == 'edge' && format('type=registry,ref={0}:edge-{1}', env.CACHE_IMAGE, matrix.arch) || '' }} + cache-to: type=registry,ref=${{ env.CACHE_IMAGE }}:${{ env.CACHE_SCOPE }}-${{ matrix.arch }},mode=max build-args: | SCREENSCRAPER_DEV_ID=${{ secrets.SCREENSCRAPER_DEV_ID }} SCREENSCRAPER_DEV_PASSWORD=${{ secrets.SCREENSCRAPER_DEV_PASSWORD }} @@ -235,6 +262,8 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + type=raw,value=edge,enable=${{ github.event_name == 'push' }} + type=sha,prefix=edge-,enable=${{ github.event_name == 'push' }} - name: Generate Docker metadata (full) id: meta @@ -247,6 +276,8 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + type=raw,value=edge,enable=${{ github.event_name == 'push' }} + type=sha,prefix=edge-,enable=${{ github.event_name == 'push' }} # Tags spanning both registries are fine here: `imagetools create` copies # the blobs over when a target sits in a different registry than the digests. diff --git a/examples/docker-compose.example.yml b/examples/docker-compose.example.yml index e86c170ea..fade19325 100644 --- a/examples/docker-compose.example.yml +++ b/examples/docker-compose.example.yml @@ -5,6 +5,7 @@ volumes: services: romm: + # `edge` tracks master: unstable, and its migrations can't be undone by returning to `latest` image: rommapp/romm:latest container_name: romm restart: unless-stopped diff --git a/frontend/src/v2/composables/useVersionDisplay/index.test.ts b/frontend/src/v2/composables/useVersionDisplay/index.test.ts index 6f33f1016..67402edee 100644 --- a/frontend/src/v2/composables/useVersionDisplay/index.test.ts +++ b/frontend/src/v2/composables/useVersionDisplay/index.test.ts @@ -57,6 +57,16 @@ describe("useVersionDisplay", () => { ); }); + it("links an edge build to the commit it was built from", () => { + heartbeatStore = makeHeartbeatStore({ + VERSION: "edge-a1b2c3d", + GIT_BRANCH: null, + }); + const { version, href } = useVersionDisplay(); + expect(version.value).toBe("edge-a1b2c3d"); + expect(href.value).toBe("https://github.com/rommapp/romm/commit/a1b2c3d"); + }); + it("encodes URL-reserved characters within a branch segment", () => { heartbeatStore = makeHeartbeatStore({ VERSION: "development", diff --git a/frontend/src/v2/composables/useVersionDisplay/index.ts b/frontend/src/v2/composables/useVersionDisplay/index.ts index 02c06f1e9..029eb7b10 100644 --- a/frontend/src/v2/composables/useVersionDisplay/index.ts +++ b/frontend/src/v2/composables/useVersionDisplay/index.ts @@ -1,8 +1,11 @@ // The version to display and where it should link. Shows the branch on a -// dev build, when known, instead of the bare "development" placeholder. +// dev build, when known, instead of the bare "development" placeholder, and +// links an edge build (`edge-`, built from master) to its commit. import { computed } from "vue"; import storeHeartbeat from "@/stores/heartbeat"; +const EDGE_VERSION_RE = /^edge-([0-9a-f]{7,40})$/; + export function useVersionDisplay() { const heartbeatStore = storeHeartbeat(); @@ -22,8 +25,12 @@ export function useVersionDisplay() { ?.split("/") .map(encodeURIComponent) .join("/"); - return encodedBranch - ? `https://github.com/rommapp/romm/tree/${encodedBranch}` + if (encodedBranch) { + return `https://github.com/rommapp/romm/tree/${encodedBranch}`; + } + const edgeCommit = EDGE_VERSION_RE.exec(version.value)?.[1]; + return edgeCommit + ? `https://github.com/rommapp/romm/commit/${edgeCommit}` : `https://github.com/rommapp/romm/releases/tag/${version.value}`; });