Skip to content

Commit 0a0c06c

Browse files
committed
ci(release): 🏗️ add build and deploy workflow to ghcr
Triggers on tag pushes (v*) or manual dispatch. Builds and pushes Docker image with semver, major.minor, major, sha, and latest tags. Validates semver and uses dynamic metadata for labels.
1 parent 6bc7f71 commit 0a0c06c

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build and Deploy to GitHub Registry
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ophiosdev/opencode-cli
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out the repo
19+
id: checkout
20+
uses: actions/checkout@v5
21+
22+
- name: Get the version
23+
id: get_version
24+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
25+
26+
- name: Validate Semver
27+
id: semver
28+
uses: matt-usurp/validate-semver@v2
29+
with:
30+
version: ${{ steps.get_version.outputs.VERSION }}
31+
32+
- name: Log in to the Container registry
33+
id: login_registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
type=semver,pattern={{major}}
49+
type=sha
50+
type=raw,value=latest,enable={{is_default_branch}}
51+
labels: |
52+
org.opencontainers.image.maintainer=Ophios GmbH
53+
- name: Build and push Docker image
54+
id: build_and_push
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
build-args: |
62+
OPENCODE_VERSION=${{ steps.get_version.outputs.VERSION }}

0 commit comments

Comments
 (0)