~bigbes/ci-cacher

ref: e8e2b2f17cf11feb30d2cfc6fd306d9dab1775c4 ci-cacher/.builds/publish.yml -rw-r--r-- 3.1 KiB
e8e2b2f1 — Eugene Blikh Add docs/index.html landing page; publish.yml substitutes build info 2 days ago
                                                                                
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Publish a linux-amd64 binary on every tag push. Two destinations:
#
#   1. Build artifact (cacher-linux-amd64 visible on the job page,
#      pruned by builds.sr.ht after 90 days).
#
#   2. pages.sr.ht under bigbes.pages.srht.bigb.es/ci-cacher/, so
#      downstream projects can `wget` from a stable URL. We publish
#      with `hut pages publish -s /ci-cacher` so this manifest only
#      touches files under that subpath — other projects sharing the
#      user-level pages domain stay intact. Latest tag overwrites the
#      previous publish under /ci-cacher; historical versions remain
#      available via the artifact link during the 90-day window.
#
# Auto-submission is restricted to tag refs only.
image: ubuntu/noble
packages:
  - curl
  - ca-certificates
oauth: pages.sr.ht/PAGES:RW
sources:
  - https://git.srht.bigb.es/~bigbes/ci-cacher
environment:
  GO_VERSION: "1.26.3"
  PATH: /home/build/.local/go/bin:/home/build/.local/bin:/home/build/go/bin:/usr/local/bin:/usr/bin:/bin
  GOPATH: /home/build/go
  PAGES_DOMAIN: bigbes.pages.srht.bigb.es
  PAGES_SUBPATH: /ci-cacher
submitter:
  git.sr.ht:
    enabled: true
    allow-refs:
      - "refs/tags/*"
tasks:
  - install_go: |
      GO_TARBALL="go${GO_VERSION}.linux-amd64.tar.gz"
      mkdir -p ~/.local
      curl -sSL "https://go.dev/dl/$GO_TARBALL" -o "/tmp/$GO_TARBALL"
      tar -xz -C ~/.local -f "/tmp/$GO_TARBALL"
      rm "/tmp/$GO_TARBALL"
      go version
  - install_hut: |
      # hut isn't in ubuntu/noble's repos; build it from source with the
      # Go we just installed. ~5s on a warm GOPATH, ~30s cold.
      go install git.sr.ht/~xenrox/hut@latest
      hut --version
  - build: |
      cd ci-cacher
      VERSION=$(git describe --tags --abbrev=0 2>/dev/null || cat VERSION)
      echo "Building $VERSION"
      GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
        go build -ldflags "-s -w -X go.bigb.es/cacher/internal/version.version=${VERSION}" \
        -o /home/build/cacher-linux-amd64 .
      /home/build/cacher-linux-amd64 version
      sha256sum /home/build/cacher-linux-amd64
  - package_pages: |
      # pages.sr.ht expects a tarball whose top-level contents map to the
      # publish path — so `tar -C dist .`, not `tar dist/`. With
      # `-s /ci-cacher` the binary lands at
      # https://$PAGES_DOMAIN/ci-cacher/cacher-linux-amd64. docs/index.html
      # is the project landing page; the three {{PLACEHOLDERS}} get
      # substituted at publish time with the values from this build.
      VERSION=$(cd ci-cacher && (git describe --tags --abbrev=0 2>/dev/null || cat VERSION))
      SUM=$(sha256sum /home/build/cacher-linux-amd64 | awk '{print $1}')
      BUILT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
      mkdir -p /home/build/dist
      cp /home/build/cacher-linux-amd64 /home/build/dist/cacher-linux-amd64
      sed -e "s|{{VERSION}}|$VERSION|g" \
          -e "s|{{SHA256}}|$SUM|g" \
          -e "s|{{BUILT}}|$BUILT|g" \
          ci-cacher/docs/index.html > /home/build/dist/index.html
      cd /home/build/dist
      tar -czvf /home/build/site.tar.gz .
  - publish_pages: |
      hut pages publish -d "$PAGES_DOMAIN" -s "$PAGES_SUBPATH" /home/build/site.tar.gz
artifacts:
  - cacher-linux-amd64