Skip to content

Commit 32e1348

Browse files
committed
share workflows
1 parent 3fc4627 commit 32e1348

File tree

6 files changed

+314
-6
lines changed

6 files changed

+314
-6
lines changed

.github/workflows/lib/ci.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-24.04
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
13+
with:
14+
submodules: recursive
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
18+
with:
19+
go-version-file: go.mod
20+
21+
- name: Install Task
22+
uses: arduino/setup-task@v2
23+
with:
24+
version: 3.x
25+
26+
- name: task generate
27+
run: |
28+
task generate --verbose
29+
git diff --exit-code
30+
31+
- name: task validate
32+
run: task validate --verbose
33+
34+
- name: task test
35+
run: task test --verbose

.github/workflows/lib/publish.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Publish
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
packages: write
8+
9+
env:
10+
OCI_URL: ghcr.io/openmcp-project
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@df432ceedc7162793a195dd1713ff69aefc7379e # 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
27+
with:
28+
token: ${{ steps.app-token.outputs.token }}
29+
fetch-tags: true
30+
fetch-depth: 0
31+
submodules: recursive
32+
33+
- name: Install Task
34+
uses: arduino/setup-task@v2
35+
with:
36+
version: 3.x
37+
38+
- name: Read and validate VERSION
39+
id: version
40+
run: |
41+
VERSION=$(task version)
42+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
43+
echo "Invalid version format: $VERSION"
44+
exit 1
45+
fi
46+
echo "New version: $VERSION"
47+
echo "version=$VERSION" >> $GITHUB_ENV
48+
49+
- name: Skip release if version is a dev version
50+
if: contains(env.version, '-dev')
51+
run: |
52+
echo "Skipping development version release: ${{ env.version }}"
53+
echo "SKIP=true" >> $GITHUB_ENV
54+
exit 0
55+
56+
- name: Set up QEMU
57+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
58+
59+
- name: Set up Docker Context for Buildx
60+
id: buildx-context
61+
run: |
62+
docker context create builders
63+
64+
- name: Login to GitHub Container Registry
65+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
66+
with:
67+
registry: ghcr.io
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Set up Docker Buildx
72+
timeout-minutes: 5
73+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
74+
with:
75+
version: latest
76+
77+
- name: Set up Go
78+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
79+
with:
80+
go-version-file: go.mod
81+
82+
- name: Build and Push Images
83+
run: |
84+
task build:img:all --verbose
85+
86+
- name: Package and Push Helm Charts
87+
run: |
88+
task build:helm:all --verbose
89+
90+
- name: Build and Push OCM Component
91+
run: |
92+
task build:ocm:all --verbose

.github/workflows/lib/release.yaml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Versioned Release
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: write # we need this to be able to push tags
8+
pull-requests: read
9+
10+
jobs:
11+
release_tag:
12+
name: Release version
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Create GitHub App token
16+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2
17+
id: app-token
18+
with:
19+
# required
20+
app-id: 1312871
21+
private-key: ${{ secrets.OPENMCP_CI_APP_PRIVATE_KEY }}
22+
23+
- name: Checkout code
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
25+
with:
26+
token: ${{ steps.app-token.outputs.token }}
27+
fetch-tags: true
28+
fetch-depth: 0
29+
submodules: recursive
30+
31+
- name: Install Task
32+
uses: arduino/setup-task@v2
33+
with:
34+
version: 3.x
35+
36+
- name: Read and validate VERSION
37+
id: version
38+
run: |
39+
VERSION=$(task version)
40+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
41+
echo "Invalid version format: $VERSION"
42+
exit 1
43+
fi
44+
echo "New version: $VERSION"
45+
echo "version=$VERSION" >> $GITHUB_ENV
46+
47+
- name: Skip release if version is a dev version
48+
if: contains(env.version, '-dev')
49+
run: |
50+
echo "Skipping development version release: ${{ env.version }}"
51+
echo "SKIP=true" >> $GITHUB_ENV
52+
exit 0
53+
54+
- name: Check if VERSION is already tagged
55+
id: check_tag
56+
run: |
57+
if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
58+
echo "Tag ${{ env.version }} already exists. Skipping release."
59+
echo "SKIP=true" >> $GITHUB_ENV
60+
exit 0
61+
fi
62+
echo "Tag ${{ env.version }} doesn't exists. Proceeding with release."
63+
64+
- name: Create Git tag
65+
if: ${{ env.SKIP != 'true' }}
66+
run: |
67+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
68+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
69+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
70+
71+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
72+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
73+
74+
git config user.name "$AUTHOR_NAME"
75+
git config user.email "$AUTHOR_EMAIL"
76+
77+
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
78+
git push origin "${{ env.version }}"
79+
80+
- name: Create Git tag for api submodule
81+
if: ${{ env.SKIP != 'true' }}
82+
run: |
83+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
84+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
85+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
86+
87+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
88+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
89+
90+
git config user.name "$AUTHOR_NAME"
91+
git config user.email "$AUTHOR_EMAIL"
92+
93+
git tag -a "api/${{ env.version }}" -m "Release ${{ env.version }}"
94+
git push origin "api/${{ env.version }}"
95+
96+
- name: Build Changelog
97+
id: github_release
98+
uses: mikepenz/release-changelog-builder-action@e92187bd633e680ebfdd15961a7c30b2d097e7ad # v5
99+
with:
100+
mode: "PR"
101+
configurationJson: |
102+
{
103+
"template": "#{{CHANGELOG}}",
104+
"pr_template": "- #{{TITLE}}: ##{{NUMBER}}",
105+
"categories": [
106+
{
107+
"title": "## Feature",
108+
"labels": ["feat", "feature"]
109+
},
110+
{
111+
"title": "## Fix",
112+
"labels": ["fix", "bug"]
113+
},
114+
{
115+
"title": "## Other",
116+
"labels": []
117+
}
118+
],
119+
"label_extractor": [
120+
{
121+
"pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
122+
"on_property": "title",
123+
"target": "$1"
124+
}
125+
]
126+
}
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
130+
- name: Create GitHub release
131+
if: ${{ env.SKIP != 'true' }}
132+
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2
133+
with:
134+
tag_name: ${{ env.version }}
135+
name: Release ${{ env.version }}
136+
body: ${{steps.github_release.outputs.changelog}}
137+
draft: true
138+
prerelease: false
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
142+
- name: Push dev VERSION
143+
if: ${{ env.SKIP != 'true' }}
144+
run: |
145+
task release:set-version --verbose -- "${{ env.version }}-dev"
146+
git config user.name "${{ env.AUTHOR_NAME }}"
147+
git config user.email "${{ env.AUTHOR_EMAIL }}"
148+
git add VERSION
149+
git commit -m "Update VERSION to ${{ env.version }}-dev"
150+
git push origin main

.github/workflows/lib/reuse.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: REUSE Compliance Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
11+
- name: REUSE Compliance Check
12+
uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Validate Pull Request Content
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate-pr-content:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Validate PR content
12+
run: |
13+
PR_BODY=$(jq -r .pull_request.body "$GITHUB_EVENT_PATH")
14+
echo "DEBUG: PR_BODY content is: $PR_BODY"
15+
REQUIRED_SECTIONS=("\\*\\*What this PR does / why we need it\\*\\*:" "\\*\\*Release note\\*\\*:")
16+
17+
for SECTION in "${REQUIRED_SECTIONS[@]}"; do
18+
echo "DEBUG: Checking for section: $SECTION"
19+
if ! echo "$PR_BODY" | grep -qE "$SECTION"; then
20+
echo "Pull request message is missing required section: $SECTION" >&2
21+
exit 1
22+
fi
23+
done

.github/workflows/reuse.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: REUSE Compliance Check
22

33
on: [push, pull_request]
44

5-
jobs:
5+
jobs:
66
test:
7-
runs-on: ubuntu-latest
8-
steps:
9-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
10-
- name: REUSE Compliance Check
11-
uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5
7+
uses: .github/workflows/lib/reuse.yaml@main

0 commit comments

Comments
 (0)