prepare-release-branch.yml 4.2 KB

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