Skip to content

Commit

Permalink
action(post-release): use fetch-depth, quoting and fix git commands (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Oct 19, 2023
1 parent 3fe4468 commit 5314fe4
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
types: [published]

permissions:
contents: write
issues: write
contents: write
issues: write
pull-requests: write

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
Expand Down Expand Up @@ -127,18 +128,22 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
depth: 0
fetch-depth: 0

- name: Setup git config
uses: elastic/apm-pipeline-library/.github/actions/setup-git@current

- name: Create GitHub Pull Request if minor release.
run: |
echo "as long as there is a major.x branch"
existed_in_local=$(git ls-remote --heads origin ${TARGET_BRANCH})
if [ -z ${existed_in_local} ]; then
if [ -z "${existed_in_local}" ]; then
echo -e "::warning::Target branch '${TARGET_BRANCH}' does not exist."
exit 0
fi
git checkout ${TARGET_BRANCH} -b ${NEW_BRANCH}
git format-patch -k --stdout ${TARGET_BRANCH}...main -- docs CHANGELOG.asciidoc | git am -3 -k
git checkout $TARGET_BRANCH
git checkout -b ${NEW_BRANCH}
git format-patch -k --stdout ${TARGET_BRANCH}...origin/main -- docs CHANGELOG.asciidoc | git am -3 -k
git push origin ${NEW_BRANCH}
gh pr create \
--title "post-release: ${GIT_TAG}" \
Expand All @@ -151,7 +156,7 @@ jobs:
run: |
echo "as long as there is no a major.x branch"
existed_in_local=$(git ls-remote --heads origin ${TARGET_BRANCH})
if [ -n ${existed_in_local} ]; then
if [ -n "${existed_in_local}" ]; then
echo -e "::warning::Target branch '${TARGET_BRANCH}' does exist."
exit 0
fi
Expand Down

0 comments on commit 5314fe4

Please sign in to comment.