prepare-release-branch.yml 4.1 KB

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