Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 36 additions & 15 deletions .github/workflows/flow-trigger-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
required: false
default: false
type: boolean
dry-run-enabled:
description: "If true, the workflow will not create a tag, but will validate the commit."
required: false
default: false
type: boolean

defaults:
run:
Expand Down Expand Up @@ -98,6 +103,7 @@ jobs:
echo "Currently on branch: ${current_branch}"

- name: Push Temporary Branch to Origin
if: ${{ inputs.dry-run-enabled != true }}
run: git push --set-upstream origin "${{ steps.branch.outputs.name }}"

- name: Git-Semver Setup Action
Expand Down Expand Up @@ -167,13 +173,16 @@ jobs:
echo "No major or minor version bump detected. Skipping release branch creation."
fi

# If this is an alpha flag we do not want to create a release branch
if [[ "${ALPHA_FLAG}" == "true" ]]; then
CREATE_RELEASE_BRANCH=false
fi

if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
echo "Dry run enabled. Skipping release branch creation."
# Create and push the release branch if CREATE_RELEASE_BRANCH is true
if [[ "${CREATE_RELEASE_BRANCH}" == "true" ]]; then
echo "Check if the release branch already exists."
elif [[ "${CREATE_RELEASE_BRANCH}" == "true" ]]; then
echo "Check if the release branch already exists."
# Check if the branch exists remotely
if git rev-list -n 1 "origin/${release_branch}" >/dev/null 2>&1; then
echo "Release branch '${release_branch}' already exists. Skipping creation."
Expand All @@ -187,23 +196,30 @@ jobs:
fi

- name: Apply Tag with Calculated Next Version
if: ${{ inputs.dry-run-enabled != true }}
run: |
echo "Applying computed version tag"
git tag --annotate "v${{ steps.next-release.outputs.version }}" --message "v${{ steps.next-release.outputs.version }}"
echo "Applied tag v${{ steps.next-release.outputs.version }}"
current_version="$(git-semver latest)"
echo "Version Tag Applied: v${{ steps.next-release.outputs.version }}" >> ${GITHUB_STEP_SUMMARY}
echo "Current Official Version: ${current_version}" >> ${GITHUB_STEP_SUMMARY}
if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
echo "Dry run enabled, not applying tag "v${{ steps.next-release.outputs.version }}"
else
git tag --annotate "v${{ steps.next-release.outputs.version }}" --message "v${{ steps.next-release.outputs.version }}"
echo "Applied tag v${{ steps.next-release.outputs.version }}"
current_version="$(git-semver latest)"
echo "Version Tag Applied: v${{ steps.next-release.outputs.version }}" >> ${GITHUB_STEP_SUMMARY}
echo "Current Official Version: ${current_version}" >> ${GITHUB_STEP_SUMMARY}
fi

- name: Push Release Tag to Remote
if: ${{ inputs.dry-run-enabled != true }}
run: |
echo "Pushing release tag to remote"
git push origin tag "v${{ steps.next-release.outputs.version }}"
echo "Pushed new release tag to remote"
echo "Pushed new release tag v${{ steps.next-release.outputs.version }} to remote"

- name: Create Release Notes with Markdown
id: release
if: ${{ inputs.alpha-release != true }} # Skip step if alpha-release is true
# Skip step if alpha-release is true, or we are dry running workflow
if: ${{ inputs.alpha-release != true || inputs.dry-run-enabled != true }}
run: |
echo git-semver log --markdown "${{ steps.next-release.outputs.version }}" > "RELEASE.md"
git-semver log --markdown "${{ steps.next-release.outputs.version }}" > "RELEASE.md"
Expand All @@ -212,7 +228,8 @@ jobs:

- name: Publish Release Notes
uses: step-security/action-gh-release@868edcd064bf35267c4b218913c3d36d547086b4 # v2.2.2
if: ${{ inputs.alpha-release != true }} # Skip step if alpha-release is true
# Skip step if alpha-release is true, or we are dry running workflow
if: ${{ inputs.alpha-release != true || inputs.dry-run-enabled != true }}
with:
name: v${{ steps.next-release.outputs.version }}
tag_name: v${{ steps.next-release.outputs.version }}
Expand All @@ -221,7 +238,8 @@ jobs:
body_path: "RELEASE.md"

- name: Clean Up Release Notes
if: ${{ inputs.alpha-release != true }} # Skip step if alpha-release is true
# Skip step if alpha-release is true, or we are dry running workflow
if: ${{ inputs.alpha-release != true || inputs.dry-run-enabled != true }}
run: |
echo "Removing the release notes file RELEASE.md"
rm RELEASE.md
Expand Down Expand Up @@ -256,10 +274,13 @@ jobs:
if: always()
run: |
echo "Deleting the temporary semantic release branch"
echo "Deleting local branch now:"
git branch -d "${{ steps.branch.outputs.name }}"
echo "Deleted Temporary Branch from Local Runner" >> ${GITHUB_STEP_SUMMARY}

echo "Deleting remote branch now:"
git push -d origin "${{ steps.branch.outputs.name }}"
echo "Deleted Temporary Branch from Remote" >> ${GITHUB_STEP_SUMMARY}
if [[ "${{ inputs.dry-run-enabled }}" == "true" ]]; then
echo "No remote branches to delete"
else
echo "Deleting remote branch now:"
git push -d origin "${{ steps.branch.outputs.name }}"
echo "Deleted Temporary Branch from Remote" >> ${GITHUB_STEP_SUMMARY}
fi
Loading