-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minor] New Action: Release PR (#10)
- Loading branch information
Showing
7 changed files
with
140 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: Lint & Test | ||
on: pull_request | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: make lint |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/bin/bash | ||
set -eou pipefail | ||
set -x | ||
IFS=$'\n\t' | ||
|
||
if [[ "${DRY_RUN:-}" == 1 ]]; then | ||
|
@@ -17,13 +16,13 @@ readonly GIT_USER="[email protected]" | |
readonly GIT_NAME="Pantheon Automation" | ||
|
||
# shellcheck disable=SC1091 | ||
source "${SELF_DIRNAME}/src/functions.sh" | ||
source "${SELF_DIRNAME}/../src/functions.sh" | ||
|
||
readonly RELEASE_BRANCH="release" | ||
readonly DEVELOP_BRANCH="main" | ||
|
||
main() { | ||
local README_MD="${2:-}" | ||
local README_MD="${1:-}" | ||
if [[ -z "$README_MD" ]]; then | ||
README_MD=README.MD | ||
fi | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Draft Release PR | ||
description: Create a PR to the release branch with all new features on the development branch. | ||
|
||
inputs: | ||
# All of these should be parameterized but right now are set in the bash script. | ||
# release_branch: | ||
# required: false | ||
# default: "release" | ||
# development_branch: | ||
# required: false | ||
# default: "main" | ||
# git_author_username: | ||
# required: false | ||
# default: "[email protected]" | ||
# git_author_username: | ||
# required: false | ||
# default: "Pantheon Automation" | ||
readme_md: # to avoid case sensitivty issues when getting the current version out of readme | ||
required: false | ||
default: "README.MD" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Draft Release PR | ||
shell: bash | ||
run: bash ${{ github.action_path }}/release-pr.sh ${{ inputs.readme_md }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
set -eou pipefail | ||
IFS=$'\n\t' | ||
|
||
# shellcheck disable=SC2155 | ||
readonly SELF_DIRNAME="$(dirname -- "$0")" | ||
|
||
# shellcheck disable=SC1091 | ||
source "${SELF_DIRNAME}/../src/functions.sh" | ||
|
||
main() { | ||
local README_MD="${1:-}" | ||
if [[ -z "$README_MD" ]]; then | ||
README_MD=README.MD | ||
fi | ||
|
||
local CURRENT_VERSION | ||
CURRENT_VERSION="$(grep 'Stable tag:' < "${README_MD}" | awk '{print $3}')" | ||
|
||
local NEW_VERSION="${CURRENT_VERSION%-dev}" | ||
local RELEASE_BRANCH="release-${NEW_VERSION}" | ||
|
||
# if local release branch exists, delete it | ||
if git show-ref --quiet --verify "refs/heads/$RELEASE_BRANCH"; then | ||
echo "> git branch -D ${RELEASE_BRANCH}" | ||
git branch -D "${RELEASE_BRANCH}" | ||
fi | ||
|
||
git checkout -b "${RELEASE_BRANCH}" | ||
echo "Updating ${CURRENT_VERSION} to ${NEW_VERSION}" | ||
# Iterate through each file in the top-level directory | ||
for file in ./*; do | ||
process_file "$file" "${CURRENT_VERSION}" "${NEW_VERSION}" | ||
done | ||
|
||
git_config | ||
|
||
RELEASE_MESSAGE="Release ${NEW_VERSION}" | ||
git commit -m "${RELEASE_MESSAGE}" | ||
git push origin "${RELEASE_BRANCH}" --force | ||
|
||
# Create a draft PR | ||
create_draft_pr RELEASE_MESSAGE | ||
if gh pr view "${RELEASE_BRANCH}"; then | ||
echo_info "PR Already Exists" | ||
return | ||
fi | ||
local PR_TITLE="${RELEASE_MESSAGE}" | ||
local PR_BODY="${RELEASE_MESSAGE}. If CI tests have not run, mark as 'ready for review' or close this PR and re-open it. | ||
For proper management of git history, merge this PR, do not squash or rebase." | ||
gh pr create --draft --base "release" \ | ||
--title "${PR_TITLE}" --body "${PR_BODY}" \ | ||
--label "automation" | ||
} | ||
|
||
main "$@" |
This file contains 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