skip highlights in actions if not found #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Versioned Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write # we need this to be able to push tags | |
| pull-requests: read | |
| issues: read | |
| env: | |
| OCI_URL: ghcr.io/openmcp-project | |
| 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: Login to GitHub Container Registry | |
| if: ${{ env.SKIP != 'true' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - 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 }} | |
| - 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 "body=" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| gh pr view "$PR_NUMBER" --json body --jq .body | |
| 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 "${{ steps.github_release.outputs.release_highlights }}" >> 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 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: Create GitHub release | |
| if: ${{ env.SKIP != 'true' }} | |
| uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # 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: Push CTF | |
| # if: ${{ env.SKIP != 'true' }} | |
| # run: | | |
| # ocm transfer ctf --overwrite ./openmcp-ctf/ ${{ env.OCI_URL }} |