Skip to content

Commit 9714048

Browse files
authored
chore: add publish action (#3)
1 parent 2e566d0 commit 9714048

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: publish
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
workflow_dispatch:
7+
8+
9+
permissions:
10+
packages: write
11+
12+
env:
13+
OCI_URL: ghcr.io/openmcp-project
14+
15+
jobs:
16+
release_tag:
17+
name: Release version
18+
runs-on: ubuntu-24.04
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
ssh-key: ${{ secrets.PUSH_KEY }}
24+
fetch-tags: true
25+
fetch-depth: 0
26+
27+
- name: Read and validate VERSION
28+
id: version
29+
run: |
30+
VERSION=$(cat VERSION)
31+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then
32+
echo "Invalid version format in VERSION file: $VERSION"
33+
exit 1
34+
fi
35+
echo "New version: $VERSION"
36+
echo "version=$VERSION" >> $GITHUB_ENV
37+
38+
- name: Skip release if version is a dev version
39+
if: contains(env.version, '-dev')
40+
run: |
41+
echo "Skipping development version release: ${{ env.version }}"
42+
echo "SKIP=true" >> $GITHUB_ENV
43+
exit 0
44+
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@v2
47+
48+
- name: Set up Docker Context for Buildx
49+
id: buildx-context
50+
run: |
51+
docker context create builders
52+
53+
- name: Login to GitHub Container Registry
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Set up Docker Buildx
61+
timeout-minutes: 5
62+
uses: docker/setup-buildx-action@v2
63+
with:
64+
version: latest
65+
66+
- name: Set up Go
67+
uses: actions/setup-go@v5
68+
with:
69+
go-version-file: go.mod
70+
71+
- name: Build the ${{ github.repository }}
72+
run: |
73+
make prepare-release
74+
make build
75+
76+
- name: Build Images
77+
run: |
78+
IMAGE_REGISTRY=ghcr.io/openmcp-project make image-build
79+
80+
- name: setup OCM
81+
uses: open-component-model/ocm-setup-action@main
82+
83+
- name: Create OCM CTF
84+
run: |
85+
ocm add componentversions --create \
86+
--file ctf component-constructor.yaml \
87+
--settings settings.yaml -- VERSION=${{ env.version }}
88+
89+
- name: Push CTF
90+
run: |
91+
ocm transfer ctf --overwrite ./ctf ${{ env.OCI_URL }}

component-constructor.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
components:
2+
- name: ${COMPONENT_NAME_PREFIX}/${COMPONENT_NAME}
3+
version: ${VERSION}
4+
provider:
5+
name: ${PROVIDER}
6+
resources:
7+
- name: ${COMPONENT_NAME}-chart
8+
type: helmChart
9+
input:
10+
type: helm
11+
path: ./charts/${COMPONENT_NAME}
12+
repository: charts/${COMPONENT_NAME}
13+
14+
- name: ${COMPONENT_NAME}-image
15+
type: ociImage
16+
input:
17+
type: dockermulti
18+
repository: images/${COMPONENT_NAME}
19+
variants:
20+
- "${COMPONENT_REPO_PREFIX}:${VERSION}-linux-amd64"
21+
- "${COMPONENT_REPO_PREFIX}:${VERSION}-linux-arm64"

settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
COMPONENT_NAME: quota-operator
2+
COMPONENT_NAME_PREFIX: github.com/openmcp-project
3+
PROVIDER: openmcp-project
4+
COMPONENT_REPO_PREFIX: ghcr.io/openmcp-project/quota-operator

0 commit comments

Comments
 (0)