aboutsummaryrefslogtreecommitdiff
path: root/justfile
blob: ebf04bb852baf8d629bc681e666034a317a2bc3b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import? 'cargo.just'

set allow-duplicate-recipes := true

name := "september"
ghcr_repo := "ghcr.io/gemrest/" + name
gitlab_repo := "registry.gitlab.com/gemrest/" + name
docker_hub_repo := "docker.io/gemrest/" + name

default:
  @just --list

fetch:
  curl https://raw.githubusercontent.com/Fuwn/justfiles/a6ca8a1b0475966ad10b68c44311ba3cb8b72a31/cargo.just > cargo.just

fmt:
  cargo +nightly fmt

# Build once, then push both `latest` and the latest git tag to all registries.
publish-images:
  #!/usr/bin/env bash

  set -euo pipefail

  git_tag="$(git describe --tags --abbrev=0)"
  docker_tag="${git_tag#v}"

  docker build --platform linux/amd64 -f Dockerfile -t {{name}}:build .

  for registry in {{ghcr_repo}} {{gitlab_repo}} {{docker_hub_repo}}; do
    docker tag {{name}}:build "$registry:latest"
    docker tag {{name}}:build "$registry:$docker_tag"
  done

  docker push "{{ghcr_repo}}:latest"
  docker push "{{ghcr_repo}}:$docker_tag"
  docker push "{{gitlab_repo}}:latest"
  docker push "{{gitlab_repo}}:$docker_tag"
  docker push "{{docker_hub_repo}}:latest"
  docker push "{{docker_hub_repo}}:$docker_tag"