Skip to content

Commit e2c76b1

Browse files
committed
chore: add release and publish workflows
1 parent ed5de1d commit e2c76b1

File tree

3 files changed

+233
-0
lines changed

3 files changed

+233
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
workflow_dispatch:
8+
9+
permissions:
10+
packages: write
11+
12+
jobs:
13+
release_tag:
14+
name: Release version
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- name: Create GitHub App token
18+
uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2
19+
id: app-token
20+
with:
21+
# required
22+
app-id: 1312871
23+
private-key: ${{ secrets.OPENMCP_CI_APP_PRIVATE_KEY }}
24+
25+
- name: Checkout code
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
27+
with:
28+
token: ${{ steps.app-token.outputs.token }}
29+
fetch-tags: true
30+
fetch-depth: 0
31+
submodules: recursive
32+
33+
- name: Read and validate VERSION
34+
id: version
35+
run: |
36+
VERSION=$(task version)
37+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
38+
echo "Invalid version format: $VERSION"
39+
exit 1
40+
fi
41+
echo "New version: $VERSION"
42+
echo "version=$VERSION" >> $GITHUB_ENV
43+
44+
- name: Skip release if version is a dev version
45+
if: contains(env.version, '-dev')
46+
run: |
47+
echo "Skipping development version release: ${{ env.version }}"
48+
echo "SKIP=true" >> $GITHUB_ENV
49+
exit 0
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
53+
54+
- name: Set up Docker Context for Buildx
55+
id: buildx-context
56+
run: |
57+
docker context create builders
58+
59+
- name: Login to GitHub Container Registry
60+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Set up Docker Buildx
67+
timeout-minutes: 5
68+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
69+
with:
70+
version: latest
71+
72+
- name: Set up Go
73+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
74+
with:
75+
go-version-file: go.mod
76+
77+
- name: Build and Push Images
78+
run: |
79+
make docker-images
80+
81+
- name: Build and Push OCM Component
82+
run: |
83+
make component

.github/workflows/release.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Versioned Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write # we need this to be able to push tags
10+
pull-requests: read
11+
12+
jobs:
13+
release_tag:
14+
name: Release version
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- name: Create GitHub App token
18+
uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2
19+
id: app-token
20+
with:
21+
# required
22+
app-id: 1312871
23+
private-key: ${{ secrets.OPENMCP_CI_APP_PRIVATE_KEY }}
24+
25+
- name: Checkout code
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
27+
with:
28+
token: ${{ steps.app-token.outputs.token }}
29+
fetch-tags: true
30+
fetch-depth: 0
31+
submodules: recursive
32+
33+
- name: Read and validate VERSION
34+
id: version
35+
run: |
36+
VERSION=$(task version)
37+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
38+
echo "Invalid version format: $VERSION"
39+
exit 1
40+
fi
41+
echo "New version: $VERSION"
42+
echo "version=$VERSION" >> $GITHUB_ENV
43+
44+
- name: Skip release if version is a dev version
45+
if: contains(env.version, '-dev')
46+
run: |
47+
echo "Skipping development version release: ${{ env.version }}"
48+
echo "SKIP=true" >> $GITHUB_ENV
49+
exit 0
50+
51+
- name: Check if VERSION is already tagged
52+
id: check_tag
53+
run: |
54+
if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
55+
echo "Tag ${{ env.version }} already exists. Skipping release."
56+
echo "SKIP=true" >> $GITHUB_ENV
57+
exit 0
58+
fi
59+
echo "Tag ${{ env.version }} doesn't exists. Proceeding with release."
60+
61+
- name: Create Git tag
62+
if: ${{ env.SKIP != 'true' }}
63+
run: |
64+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
65+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
66+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
67+
68+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
69+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
70+
71+
git config user.name "$AUTHOR_NAME"
72+
git config user.email "$AUTHOR_EMAIL"
73+
74+
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
75+
git push origin "${{ env.version }}"
76+
77+
NESTED_GO_MODULES="$(task release:list-nested-modules)"
78+
79+
for MODULE in $NESTED_GO_MODULES; do
80+
git tag -a "${MODULE}/${{ env.version }}" -m "Release ${{ env.version }}"
81+
git push origin "${MODULE}/${{ env.version }}"
82+
done
83+
84+
- name: Create GitHub release
85+
if: ${{ env.SKIP != 'true' }}
86+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
87+
with:
88+
tag_name: ${{ env.version }}
89+
name: Release ${{ env.version }}
90+
body: ""
91+
draft: true
92+
prerelease: false
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
96+
- name: Push dev VERSION
97+
if: ${{ env.SKIP != 'true' }}
98+
run: |
99+
echo "${{ env.version }}-dev" > VERSION
100+
101+
sed -i -e "0,/)/{[email protected]/openmcp-project/landscaper/apis .*@github.com/openmcp-project/landscaper/apis v0.0.0-00010101000000-000000000000@}" \
102+
go.mod
103+
104+
sed -i -e "0,/)/{[email protected]/openmcp-project/landscaper/controller-utils .*@github.com/openmcp-project/landscaper/controller-utils v0.0.0-00010101000000-000000000000@}" \
105+
go.mod
106+
107+
sed -i -e "0,/)/{[email protected]/openmcp-project/landscaper/apis .*@github.com/openmcp-project/landscaper/apis v0.0.0-00010101000000-000000000000@}" \
108+
controller-utils/go.mod
109+
110+
git config user.name "${{ env.AUTHOR_NAME }}"
111+
git config user.email "${{ env.AUTHOR_EMAIL }}"
112+
git add VERSION
113+
git add go.mod
114+
git add controller-utils/go.mod
115+
git commit -m "chore(release): Update VERSION to ${{ env.version }}-dev"
116+
git push origin main

hack/release.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
PROJECT_ROOT="$(realpath $(dirname $0)/..)"
6+
7+
echo "Landscaper release: updating go.mod files"
8+
9+
# update go.mod's internal dependency to local module so that it can be used by other repositories
10+
VERSION=$(cat ${PROJECT_ROOT}/VERSION)
11+
12+
# 0,/)/ only replaces the first ocurrence until the first dep block with ')' is reached
13+
sed -i -e "0,/)/{[email protected]/openmcp-project/landscaper/apis .*@github.com/openmcp-project/landscaper/apis ${VERSION}@}" \
14+
${PROJECT_ROOT}/go.mod
15+
16+
sed -i -e "0,/)/{[email protected]/openmcp-project/landscaper/controller-utils .*@github.com/openmcp-project/landscaper/controller-utils ${VERSION}@}" \
17+
${PROJECT_ROOT}/go.mod
18+
19+
sed -i -e "0,/)/{[email protected]/openmcp-project/landscaper/apis .*@github.com/openmcp-project/landscaper/apis ${VERSION}@}" \
20+
${PROJECT_ROOT}/controller-utils/go.mod
21+
22+
echo "Landscaper release: starting revendor"
23+
24+
(
25+
cd $PROJECT_ROOT
26+
make revendor
27+
)
28+
29+
echo "Landscaper release: finished revendor"
30+
31+
# the helm chart versions need to be updated in the release step to reflect the change in the Git repository
32+
${PROJECT_ROOT}/hack/update-helm-chart-version.sh
33+
34+
echo "Landscaper release: finished"

0 commit comments

Comments
 (0)