Skip to content

docs: improve readme (#24) #37

docs: improve readme (#24)

docs: improve readme (#24) #37

Workflow file for this run

name: Versioned Release
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write # we need this to be able to push tags
pull-requests: read # we need this to be able to read pull-requests body
issues: read # we need this to be able to read pull-requests body
packages: write # we need this to be able to push ocm packages
attestations: write # we need this to be able to push ocm packages
id-token: write # we need this to be able to push ocm packages
env:
OCI_URL: ghcr.io/openmcp-project/components
jobs:
release_tag:
name: Release version
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ssh-key: ${{ secrets.PUSH_KEY }}
fetch-tags: true
fetch-depth: 0
submodules: recursive
- name: Read and validate VERSION
id: version
run: |
VERSION=$(cat VERSION)
if [[ ! "$VERSION" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
echo "Invalid version format: $VERSION"
exit 1
fi
echo "New version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
- name: Check if VERSION is already tagged
id: check_tag
run: |
if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
echo "Tag ${{ env.version }} already exists. Skipping release."
echo "SKIP=true" >> $GITHUB_ENV
exit 0
fi
echo "Tag ${{ env.version }} doesn't exists. Proceeding with release."
- name: Skip release if version is a dev version
if: contains(env.version, '-dev')
run: |
echo "Skipping development version release: ${{ env.version }}"
echo "SKIP=true" >> $GITHUB_ENV
exit 0
- name: Create Git tag
if: ${{ env.SKIP != 'true' }}
run: |
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
git config user.name "$AUTHOR_NAME"
git config user.email "$AUTHOR_EMAIL"
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
git push origin "${{ env.version }}"
- name: setup OCM
if: ${{ env.SKIP != 'true' }}
uses: open-component-model/ocm-setup-action@main
- name: Create OCM CTF
if: ${{ env.SKIP != 'true' }}
run: |
ocm add componentversions --create \
--file openmcp-ctf component-constructor.yaml \
--settings components-versions.yaml -- OPENMCP_VERSION=${{ env.version }} OPENMCP_VERSION_COMMIT=$(git show-ref --hash ${{ env.version }})
- name: Get PR body for current commit
id: release_highlights
if: ${{ env.SKIP != 'true' }}
run: |
COMMIT_SHA=$(git rev-parse HEAD)
PR_NUMBER=$(gh pr list --search "$COMMIT_SHA" --state merged --json number --jq '.[0].number')
if [ -z "$PR_NUMBER" ]; then
echo "No PR found for commit $COMMIT_SHA, skipping."
echo "pr_body=" >> "$GITHUB_ENV"
exit 0
fi
echo "pr_body=\"$(gh pr view "$PR_NUMBER" --json body --jq .body)\"" >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Build Changelog
if: ${{ env.SKIP != 'true' }}
id: constructed_release
run: |
cat hack/release-body.tpl > RELEASE_BODY.md
echo "${{ env.pr_body }}" >> RELEASE_BODY.md
echo -e "## Components:\n" >> RELEASE_BODY.md
./hack/generate_release_notes.sh openmcp-ctf >> RELEASE_BODY.md
env:
GH_TOKEN: ${{ github.token }}
- name: Create GitHub release
if: ${{ env.SKIP != 'true' }}
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
with:
tag_name: ${{ env.version }}
name: Release ${{ env.version }}
body_path: RELEASE_BODY.md
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ env.SKIP != 'true' }}
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push CTF
if: ${{ env.SKIP != 'true' }}
run: |
ocm transfer ctf ./openmcp-ctf/ ${{ env.OCI_URL }}