prepare-patch-release.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. name: Prepare patch release
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. prepare-patch-release:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v3
  9. - run: |
  10. if [[ ! $GITHUB_REF_NAME =~ ^release/v[0-9]+\.[0-9]+\.x$ ]]; then
  11. echo this workflow should only be run against release branches
  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. - name: Set environment variables
  19. run: |
  20. version=$(.github/scripts/get-version.sh)
  21. if [[ $version =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then
  22. major_minor="${BASH_REMATCH[1]}"
  23. patch="${BASH_REMATCH[2]}"
  24. else
  25. echo "unexpected version: $version"
  26. exit 1
  27. fi
  28. echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
  29. - name: Update version
  30. run: .github/scripts/update-version.sh $VERSION
  31. - name: Update download link version
  32. run: |
  33. sed -Ei "s,https://github\.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v[0-9]+\.[0-9]+\.[0-9]+/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$VERSION/," README.md
  34. - name: Update the change log with the approximate release date
  35. run: |
  36. date=$(date "+%Y-%m-%d")
  37. sed -Ei "s/^## Unreleased$/## Version $VERSION ($date)/" CHANGELOG.md
  38. - name: Set git user
  39. run: .github/scripts/set-git-user.sh
  40. - name: Create pull request
  41. env:
  42. # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
  43. GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
  44. run: |
  45. message="Prepare release $VERSION"
  46. branch="prepare-release-${VERSION}"
  47. git commit -a -m "$message"
  48. git push origin HEAD:$branch
  49. gh pr create --title "[$GITHUB_REF_NAME] $message" \
  50. --body "$message." \
  51. --head $branch \
  52. --base $GITHUB_REF_NAME