prepare-release-branch.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: Prepare release branch
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. create-pull-request-against-release-branch:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v3
  9. - name: Create release branch
  10. id: create-release-branch
  11. run: |
  12. version=$(.github/scripts/get-version.sh)
  13. version=${version//-SNAPSHOT/}
  14. release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/release\/v\1.\2.x/')
  15. git push origin HEAD:$release_branch_name
  16. echo "VERSION=$version" >> $GITHUB_ENV
  17. echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
  18. - name: Update version
  19. run: .github/scripts/update-version.sh $VERSION ${VERSION}-alpha
  20. - name: Update download link version
  21. run: |
  22. version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts)
  23. sed -Ei "s,https://github\.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/," README.md
  24. - name: Set git user
  25. run: .github/scripts/set-git-user.sh
  26. - name: Create pull request against the release branch
  27. env:
  28. # not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
  29. GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
  30. run: |
  31. message="Prepare release $VERSION"
  32. branch="prepare-release-${VERSION}"
  33. git commit -a -m "$message"
  34. git push origin HEAD:$branch
  35. gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
  36. --body "$message." \
  37. --head $branch \
  38. --base $RELEASE_BRANCH_NAME
  39. create-pull-request-against-main:
  40. runs-on: ubuntu-latest
  41. steps:
  42. - uses: actions/checkout@v3
  43. - name: Set environment variables
  44. run: |
  45. version=$(.github/scripts/get-version.sh)
  46. if [[ $version =~ ([0-9]+)\.([0-9]+)\.0 ]]; then
  47. major="${BASH_REMATCH[1]}"
  48. minor="${BASH_REMATCH[2]}"
  49. else
  50. echo "unexpected version: $version"
  51. exit 1
  52. fi
  53. next_version="$major.$((minor + 1)).0"
  54. next_version="${next_version}-SNAPSHOT"
  55. echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV
  56. - name: Update version
  57. run: |
  58. next_alpha_version=${NEXT_VERSION//-SNAPSHOT/}-alpha-SNAPSHOT
  59. .github/scripts/update-version.sh $NEXT_VERSION $NEXT_ALPHA_VERSION
  60. - name: Set git user
  61. run: .github/scripts/set-git-user.sh
  62. - name: Create pull request against main
  63. env:
  64. # not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
  65. GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
  66. run: |
  67. message="Update version to $NEXT_VERSION"
  68. body="Update version to \`$NEXT_VERSION\`."
  69. branch="update-version-to-${NEXT_VERSION}"
  70. git commit -a -m "$message"
  71. git push origin HEAD:$branch
  72. gh pr create --title "$message" \
  73. --body "$body" \
  74. --head $branch \
  75. --base main