prepare-release-branch.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. name: Prepare release branch
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. prereqs:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v4
  9. - name: Verify prerequisites
  10. run: |
  11. if [[ $GITHUB_REF_NAME != main ]]; then
  12. echo this workflow should only be run against main
  13. exit 1
  14. fi
  15. if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then
  16. echo the change log is missing an \"Unreleased\" section
  17. exit 1
  18. fi
  19. create-pull-request-against-release-branch:
  20. runs-on: ubuntu-latest
  21. needs:
  22. - prereqs
  23. steps:
  24. - uses: actions/checkout@v4
  25. - name: Create release branch
  26. run: |
  27. version=$(.github/scripts/get-version.sh)
  28. version=${version//-SNAPSHOT/}
  29. if [[ $version =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then
  30. release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/release\/v\1.\2.x/')
  31. else
  32. echo "unexpected version: $version"
  33. exit 1
  34. fi
  35. git push origin HEAD:$release_branch_name
  36. echo "VERSION=$version" >> $GITHUB_ENV
  37. echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
  38. - name: Update version
  39. run: .github/scripts/update-version.sh $VERSION
  40. - name: Update download link version
  41. run: |
  42. 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
  43. - name: Update the change log with the approximate release date
  44. run: |
  45. date=$(date "+%Y-%m-%d")
  46. sed -Ei "s/^## Unreleased$/## Version $VERSION ($date)/" CHANGELOG.md
  47. - name: Use CLA approved github bot
  48. run: .github/scripts/use-cla-approved-github-bot.sh
  49. - name: Create pull request against the release branch
  50. env:
  51. # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
  52. GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
  53. run: |
  54. message="Prepare release $VERSION"
  55. branch="opentelemetrybot/prepare-release-${VERSION}"
  56. git checkout -b $branch
  57. git commit -a -m "$message"
  58. git push --set-upstream origin $branch
  59. gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
  60. --body "$message." \
  61. --base $RELEASE_BRANCH_NAME
  62. create-pull-request-against-main:
  63. runs-on: ubuntu-latest
  64. needs:
  65. - prereqs
  66. steps:
  67. - uses: actions/checkout@v4
  68. - name: Set environment variables
  69. run: |
  70. version=$(.github/scripts/get-version.sh)
  71. version=${version//-SNAPSHOT/}
  72. if [[ $version =~ ^([0-9]+)\.([0-9]+)\.0$ ]]; then
  73. major="${BASH_REMATCH[1]}"
  74. minor="${BASH_REMATCH[2]}"
  75. next_version="$major.$((minor + 1)).0"
  76. else
  77. echo "unexpected version: $version"
  78. exit 1
  79. fi
  80. echo "NEXT_VERSION=${next_version}-SNAPSHOT" >> $GITHUB_ENV
  81. echo "VERSION=$version" >> $GITHUB_ENV
  82. - name: Update version
  83. run: .github/scripts/update-version.sh $NEXT_VERSION
  84. - name: Update the change log on main
  85. run: |
  86. # the actual release date on main will be updated at the end of the release workflow
  87. date=$(date "+%Y-%m-%d")
  88. sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version $VERSION ($date)/" CHANGELOG.md
  89. - name: Use CLA approved github bot
  90. run: .github/scripts/use-cla-approved-github-bot.sh
  91. - name: Create pull request against main
  92. env:
  93. # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
  94. GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
  95. run: |
  96. message="Update version to $NEXT_VERSION"
  97. body="Update version to \`$NEXT_VERSION\`."
  98. branch="opentelemetrybot/update-version-to-${NEXT_VERSION}"
  99. git checkout -b $branch
  100. git commit -a -m "$message"
  101. git push --set-upstream origin $branch
  102. gh pr create --title "$message" \
  103. --body "$body" \
  104. --base main