Skip to content

Prepare release branch #9

Prepare release branch

Prepare release branch #9

name: Prepare release branch
on:
workflow_dispatch:
jobs:
prereqs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Verify prerequisites
run: |
if [[ $GITHUB_REF_NAME != main ]]; then
echo this workflow should only be run against main
exit 1
fi
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then
echo the change log is missing an \"Unreleased\" section
exit 1
fi
create-pull-request-against-release-branch:
runs-on: ubuntu-latest
needs:
- prereqs
steps:
- uses: actions/checkout@v3
- name: Create release branch
run: |
version=$(.github/scripts/get-version.sh)
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
release_branch_name="release/v${version}"
release_branch_exists=$(git ls-remote --heads origin refs/heads/$release_branch_name)
if [[ $release_branch_exists != "" ]] ; then
echo "release branch $release_branch_name already exists"
exit 1
fi
else
echo "unexpected version: $version"
exit 1
fi
git push origin HEAD:$release_branch_name
echo "VERSION=$version" >> $GITHUB_ENV
echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
- name: Update version
run: sed -Ei "s/val snapshot = true/val snapshot = false/" build.gradle.kts
- name: Update the change log with the approximate release date
run: |
date=$(date "+%Y-%m-%d")
sed -Ei "s/^## Unreleased$/## Version $VERSION ($date)/" CHANGELOG.md
- name: Use CLA approved github bot
run: .github/scripts/use-cla-approved-github-bot.sh
- name: Create pull request against the release branch
env:
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
run: |
message="Prepare release $VERSION"
branch="opentelemetrybot/prepare-release-${VERSION}"
git checkout -b $branch
git commit -a -m "$message"
git push --set-upstream origin $branch
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
--body "$message." \
--base $RELEASE_BRANCH_NAME
create-pull-request-against-main:
runs-on: ubuntu-latest
needs:
- prereqs
steps:
- uses: actions/checkout@v3
- name: Set environment variables
run: |
version=$(.github/scripts/get-version.sh)
if [[ ! $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "unexpected version: $version"
exit 1
fi
echo "VERSION=$version" >> $GITHUB_ENV
- name: Update the change log on main
run: |
# the actual release date on main will be updated at the end of the release workflow
date=$(date "+%Y-%m-%d")
sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version $VERSION ($date)/" CHANGELOG.md
- name: Use CLA approved github bot
run: .github/scripts/use-cla-approved-github-bot.sh
- name: Create pull request against main
env:
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
run: |
message="Update changelog for $VERSION release"
body="Update changelog for \`$VERSION\` release."
branch="opentelemetrybot/update-version-to-${VERSION}"
git checkout -b $branch
git commit -a -m "$message"
git push --set-upstream origin $branch
gh pr create --title "$message" \
--body "$body" \
--base main