Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(release): add pre-release workflow to create version bump PR #2774

Merged
merged 6 commits into from
Jun 20, 2024
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
16 changes: 16 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ jobs:
- name: restore_gosum
run: echo "${{needs.gomod.outputs.gosum}}" > go.sum
- run: make golint

reno_lint:
runs-on: ubuntu-20.04
needs: gomod
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 0
- name: reset_git_extension
run: git config --unset-all extensions.worktreeconfig
- name: reno_lint
run: make reno-lint
## Reno lint does not catch some errors which make reno report fail
- name: reno_report_check
run: make reno-report

test:
runs-on: ubuntu-20.04
needs: gomod
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/pre-release.yml
viveksinghggits marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Pre release

on:
workflow_dispatch:
inputs:
release_tag:
description: 'Image tag in the format x.x.x'
required: true
type: string

env:
RELEASE_TAG: ${{ inputs.release_tag }}
PRERELEASE_DOCS_BRANCH: 'dg8d45z'

jobs:
## TODO we can add a condition like github.actor.role == 'Maintainer' to limit trigger to maintainers only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do this as part of this PR itself? I think we should.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not yet supported, but there's active discussion ongoing. When it's implemented, we can do that.

create_pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: checkout_repo
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0 # necessary for CURRENT_TAG tracing
- name: fetch_tags
run: git fetch --tags origin
- name: bump_version
run: |
export CURRENT_TAG=$(git describe --abbrev=0 --tags)
echo ./build/bump_version.sh "${CURRENT_TAG}" "${RELEASE_TAG}"
./build/bump_version.sh "${CURRENT_TAG}" "${RELEASE_TAG}"
make reno-report VERSION="${RELEASE_TAG}"
- name: commit_changes
run: |
git config --global user.name 'Kasten Production'
git config --global user.email '[email protected]'
git checkout -B "kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG}"
git add -A
git commit -s -m "pre-release: Update version to ${RELEASE_TAG}"
- name: push_changes
run: git push origin "kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG}"
- name: create_pr_body
run: |
echo "Update version to ${RELEASE_TAG}" > PR_BODY_FILE
echo "" >> PR_BODY_FILE
echo "Please check the changelog for the following merges:" >> PR_BODY_FILE
export CURRENT_TAG=$(git describe --abbrev=0 --tags)
git log ${CURRENT_TAG}..kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG} --pretty="- %h: %s" | grep -v ': test' | grep -v ': doc' | grep -v ': build' | grep -v ': deps' >> PR_BODY_FILE
- name: create_pr
run: |
gh pr create --title "pre-release: Update version to ${RELEASE_TAG}" -F PR_BODY_FILE --head "kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG}" --base master --reviewer pavannd1,viveksinghggits,hairyhum --label kueue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
**/*.swp
/.idea
/releasenotes/config.yaml
CHANGELOG.rst
CHANGELOG_CURRENT.rst
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,6 @@ changelog:
exclude:
- '^docs:'
- '^test:'
- '^pre-release:'
archives:
- allow_different_binary_count: true
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,6 @@ reno-new:

reno-report:
@$(MAKE) run CMD="./build/reno_report.sh $(VERSION)"

reno-lint:
@$(MAKE) run CMD="reno lint"
3 changes: 3 additions & 0 deletions build/gorelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ then
exit 1
fi

## Set default changelog file
CHANGELOG_FILE=${CHANGELOG_FILE:-./CHANGELOG_CURRENT.md}

RELEASE_NOTES=""
if [ -n "${CHANGELOG_FILE:-}" ]
then
Expand Down
13 changes: 8 additions & 5 deletions build/reno_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ rst2md ./CHANGELOG.rst --output ./CHANGELOG.md
## It will be replaced by `unreleased_version_title` setting in the actual report file
UNRELEASED_VERSION=$(reno list 2>/dev/null | grep -E "^[0-9]+\.[0-9]+\.[0-9]+\-[0-9]+")

## Generate rst report
echo reno report --version=${UNRELEASED_VERSION} --output ./CHANGELOG_CURRENT.rst
reno report --version=${UNRELEASED_VERSION} --output ./CHANGELOG_CURRENT.rst
## Convert rst to markdown
rst2md ./CHANGELOG_CURRENT.rst --output ./CHANGELOG_CURRENT.md
if [ -n "${UNRELEASED_VERSION}" ]
then
## Generate rst report
echo reno report --version=${UNRELEASED_VERSION} --output ./CHANGELOG_CURRENT.rst
reno report --version=${UNRELEASED_VERSION} --output ./CHANGELOG_CURRENT.rst
## Convert rst to markdown
rst2md ./CHANGELOG_CURRENT.rst --output ./CHANGELOG_CURRENT.md
fi