Skip to content

Commit

Permalink
chore: always create a new release branch and delete all old ones dur…
Browse files Browse the repository at this point in the history
…ing new release action (#894)

#### What this PR does / why we need it

When we create a new release, then let's always be prepared for a
potential hotfix and create the release branch.
On the other hand, this will create a lot of unused branches over the
time, so the PR will delete all older release branches.
In case of serious situation, where we really need to fix older
versions, we still have the tags in place and would need to create
manually a patched old release.

#### Which issue(s) this PR fixes

releates open-component-model/ocm-project#240
  • Loading branch information
hilmarf authored Aug 28, 2024
1 parent d314584 commit 3af44f8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
File renamed without changes.
4 changes: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
labels: kind/skip-release-notes
---

<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
- name: Setup lint
run: |
make -f hack/Makefile golangci-lint
#curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
- name: Lint
run: |
PATH=$PATH:$(go env GOPATH)/bin make check
Expand All @@ -78,7 +77,7 @@ jobs:
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -103,4 +102,3 @@ jobs:
- name: Check for diff
run: |
git diff --exit-code --shortstat
32 changes: 16 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ on:
inputs:
release_candidate:
type: boolean
description: "Release Candidate"
required: false
default: false
create_branch:
type: boolean
description: "Create Release Branch"
description: 'Release Candidate'
required: false
default: false
prerelease:
type: string
description: "Release Candidate Name"
description: 'Release Candidate Name'
required: false
default: ""
default: ''

jobs:
check:
Expand Down Expand Up @@ -46,11 +41,6 @@ jobs:
else
v="v$(go run $GITHUB_WORKSPACE/api/version/generate print-version)"
echo "Final Release: $v"
if ${{ github.event.inputs.create_branch }}; then
echo "with release branch creation"
else
echo "without release branch creation"
fi
fi
- name: Set Base Version
Expand Down Expand Up @@ -79,7 +69,7 @@ jobs:
fi
- name: Check Branch
if: inputs.release_candidate == false && inputs.create_branch
if: inputs.release_candidate == false && github.ref == 'refs/heads/main'
run: |
set -e
if git ls-remote --exit-code origin refs/heads/releases/${{ env.RELEASE_VERSION }} ; then
Expand Down Expand Up @@ -225,7 +215,7 @@ jobs:
with:
distribution: goreleaser
version: 2.1.0
args: release --clean --timeout 60m --skip=validate --config=./.goreleaser.yaml --release-notes=${{ env.RELEASE_NOTES_FILE }}
args: release --clean --timeout 60m --skip=validate --config=.github/config/goreleaser.yaml --release-notes=${{ env.RELEASE_NOTES_FILE }}
env:
GITHUBORG: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -240,7 +230,7 @@ jobs:
run: make plain-push

- name: Create Release Branch
if: inputs.release_candidate == false && inputs.create_branch
if: inputs.release_candidate == false && github.ref == 'refs/heads/main'
run: |
n="releases/${{env.RELEASE_VERSION}}"
git checkout -b "$n"
Expand All @@ -262,6 +252,16 @@ jobs:
git push origin ${GITHUB_REF#refs/heads/}
echo "Next branch version is $v"
- name: Delete Older Release Branches
if: github.ref == 'refs/heads/main'
run: |
set -e
git fetch --prune
for branch in $(git branch -r | grep 'origin/releases/' | grep -v 'origin/releases/${{ env.RELEASE_VERSION }}'); do
branch_name=$(echo $branch | sed 's|origin/||')
echo "Deleting branch $branch_name"
done
- name: Publish Release Event
if: inputs.release_candidate == false
uses: peter-evans/repository-dispatch@v3
Expand Down

0 comments on commit 3af44f8

Please sign in to comment.