Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions .github/workflows/kind-cats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CF Acceptance Tests on KinD

on:
schedule:
- cron: '0 6 * * *'
- cron: '0 6 * * 1'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -77,4 +77,3 @@ jobs:
with:
name: report
path: ./cf-acceptance-tests/report.json

80 changes: 80 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release

on:
workflow_run:
workflows: ["CF Acceptance Tests on KinD"]
types: [completed]
branches: [main]

jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Get commit info and calculate next version
id: commit-info
run: |
COMMIT_SHA=${{ github.event.workflow_run.head_sha }}
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT

# Get latest tag
LATEST_TAG=$(gh release view --json tagName --jq '.tagName' 2>/dev/null || echo "")

# Remove 'v' prefix if present
VERSION=${LATEST_TAG#v}

# Parse major.minor.patch
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Increment patch
PATCH=$((PATCH + 1))
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"

echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Latest tag: ${LATEST_TAG:-none}, New version: $NEW_VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check if version already released
id: check-existing-release
run: |
COMMIT_SHA=${{ steps.commit-info.outputs.commit_sha }}

# Compare this run's commit to the latest release target commit.
LATEST_RELEASE_COMMIT=$(gh release view --json targetCommitish --jq '.targetCommitish' 2>/dev/null || echo "")

if [ -z "$LATEST_RELEASE_COMMIT" ]; then
echo "should_create_release=true" >> $GITHUB_OUTPUT
echo "No previous release found; release will be created"
elif [ "$LATEST_RELEASE_COMMIT" = "$COMMIT_SHA" ]; then
echo "should_create_release=false" >> $GITHUB_OUTPUT
echo "Latest release already points to commit $COMMIT_SHA"
else
echo "should_create_release=true" >> $GITHUB_OUTPUT
echo "Latest release commit differs ($LATEST_RELEASE_COMMIT); release will be created"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
if: steps.check-existing-release.outputs.should_create_release == 'true'
run: |
NEW_VERSION=${{ steps.commit-info.outputs.new_version }}
COMMIT_SHA=${{ steps.commit-info.outputs.commit_sha }}

gh release create "$NEW_VERSION" \
--target "$COMMIT_SHA" \
--title "Release $NEW_VERSION" \
--notes "Automated release for commit ${COMMIT_SHA:0:7}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release Summary
if: steps.check-existing-release.outputs.should_create_release == 'true'
run: |
echo "### Release Workflow Summary" >> $GITHUB_STEP_SUMMARY
echo "- Commit SHA: ${{ steps.commit-info.outputs.commit_sha }}" >> $GITHUB_STEP_SUMMARY
echo "- New Version: ${{ steps.commit-info.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "- Release Created: ${{ steps.check-existing-release.outputs.should_create_release == 'true' && 'Yes' || 'No (latest release already targets this commit)' }}" >> $GITHUB_STEP_SUMMARY