-
Notifications
You must be signed in to change notification settings - Fork 5
104 lines (93 loc) · 3.57 KB
/
Copy pathdocker-publish.yml
File metadata and controls
104 lines (93 loc) · 3.57 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Docker Publish
# Builds and pushes the official runtime image
# ghcr.io/objectstack-ai/objectstack from docker/Dockerfile.
#
# Two entry points:
# - workflow_call: invoked by release.yml right after a successful
# `changeset publish`, with the just-published @objectstack/cli version.
# (A plain `on: push: tags:` trigger would never fire — the release
# workflow pushes its tags with GITHUB_TOKEN, and GitHub suppresses
# workflow triggers from GITHUB_TOKEN-pushed refs.)
# - workflow_dispatch: manual backfill / rebuild of an already-published
# version, e.g. to pick up node:22-slim base-image CVE patches between
# framework releases.
#
# The image tag always equals the @objectstack/cli version baked inside.
on:
workflow_call:
inputs:
version:
description: 'Published @objectstack/cli version to package (e.g. 14.8.0)'
required: true
type: string
workflow_dispatch:
inputs:
version:
description: '@objectstack/cli version to package (e.g. 14.8.0) — must already be on npm'
required: true
type: string
permissions:
contents: read
jobs:
publish:
name: Build & push ghcr.io/objectstack-ai/objectstack
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE: ghcr.io/objectstack-ai/objectstack
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Validate version input
id: version
env:
VERSION: ${{ inputs.version }}
run: |
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$'; then
echo "::error::'$VERSION' is not a valid semver version"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Set up QEMU (arm64 emulation)
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to ghcr.io
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
# Tag = CLI version. Rolling minor/major/latest tags move with every
# publish; prereleases (x.y.z-rc.1) get only their exact tag.
tags: |
type=semver,pattern={{version}},value=${{ steps.version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }}
type=semver,pattern={{major}},value=${{ steps.version.outputs.version }}
type=raw,value=latest,enable=${{ !contains(steps.version.outputs.version, '-') }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: docker
platforms: linux/amd64,linux/arm64
push: true
build-args: |
OS_CLI_VERSION=${{ steps.version.outputs.version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Smoke-test the pushed image (amd64)
# `os --version` proves the CLI resolved, installed, and runs on the
# pushed image; a boot test needs an artifact + DB and belongs to the
# examples/e2e suites, not here.
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
docker pull "$IMAGE:$VERSION"
docker run --rm "$IMAGE:$VERSION" os --version