prepare-release-branch.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts)
  13. release_branch_name=$(echo $version | sed -E 's,([0-9]+)\.([0-9]+)\.0,release/v\1.\2.x,')
  14. git push origin HEAD:$release_branch_name
  15. echo "VERSION=$version" >> $GITHUB_ENV
  16. echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
  17. - name: Update version
  18. run: |
  19. sed -ri "s/val snapshot = true/val snapshot = false/" version.gradle.kts
  20. version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts)
  21. .github/scripts/update-examples.sh "$version"
  22. - name: Update download link version
  23. run: |
  24. version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts)
  25. 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
  26. - name: Set git user
  27. run: |
  28. git config user.name opentelemetry-java-bot
  29. git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
  30. - name: Create pull request against the release branch
  31. env:
  32. GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
  33. run: |
  34. message="Prepare release $VERSION"
  35. branch=prepare-release-$VERSION
  36. git commit -a -m "$message"
  37. git push origin HEAD:$branch
  38. gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
  39. --body "$message." \
  40. --head $branch \
  41. --base $RELEASE_BRANCH_NAME
  42. create-pull-request-against-main:
  43. runs-on: ubuntu-latest
  44. steps:
  45. - uses: actions/checkout@v3
  46. - name: Update version
  47. run: |
  48. version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts)
  49. if [[ $version =~ ([0-9]+).([0-9]+).0 ]]; then
  50. major="${BASH_REMATCH[1]}"
  51. minor="${BASH_REMATCH[2]}"
  52. else
  53. echo "unexpected version: $version"
  54. exit 1
  55. fi
  56. next_version="$major.$((minor + 1)).0"
  57. sed -ri "s/[0-9]+\.[0-9]+\.[0-9]+/$next_version/" version.gradle.kts
  58. .github/scripts/update-examples.sh "$next_version-SNAPSHOT"
  59. echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV
  60. - name: Set git user
  61. run: |
  62. git config user.name opentelemetry-java-bot
  63. git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
  64. - name: Create pull request against main
  65. env:
  66. GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
  67. run: |
  68. message="Update version to $NEXT_VERSION-SNAPSHOT"
  69. body="Update version to \`$NEXT_VERSION-SNAPSHOT\`."
  70. branch=update-version-to-$NEXT_VERSION-snapshot
  71. git commit -a -m "$message"
  72. git push origin HEAD:$branch
  73. gh pr create --title "$message" \
  74. --body "$body" \
  75. --head $branch \
  76. --base main