-
Notifications
You must be signed in to change notification settings - Fork 798
Automate per-package release for specific components #2875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3eb7e29
Per package release
5ac2256
update docs and some fixes
87921e6
up
79cb61a
up
517d09d
feedback
78ed3b4
DELETEME
196bc6d
Update opentelemetry-resource-detector-azure version to v0.2.0
opentelemetrybot 50471c8
Update build_a_package.sh
f62ee18
Copy changelog updates from package-release/opentelemetry-resource-de…
opentelemetrybot c9175ea
up
294878b
lint
76a5d70
review and reuse notes/changelog script across workflows
bcd66a7
some fixes
0b6585a
undo test changes
a745b7d
clean up
6505ad8
try me
6dfd902
support version.py and version/__init__.py files
3da5ac8
test instr version
08444e8
exclude from release
0c729ea
uo
1084a01
uo
407b8f1
uo
595e9b6
up
b393d20
clean up
e0b5501
lint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: "[Package] Prepare patch release" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
package: | ||
type: choice | ||
options: | ||
- opentelemetry-propagator-aws-xray | ||
- opentelemetry-resource-detector-azure | ||
- opentelemetry-sdk-extension-aws | ||
lmolkova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: 'Package to be released' | ||
required: true | ||
jobs: | ||
prepare-patch-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Verify prerequisites | ||
run: | | ||
if [[ $GITHUB_REF_NAME != package-release/${{ inputs.package }}/v* ]]; then | ||
echo this workflow should only be run against package-release/${{ inputs.package }}* branches, but is running on $GITHUB_REF_NAME | ||
exit 1 | ||
fi | ||
|
||
path=./$(./scripts/eachdist.py find-package --package ${{ inputs.package }}) | ||
changelog=$path/CHANGELOG.md | ||
|
||
if [ ! -f $changelog ]; then | ||
echo "missing $changelog file" | ||
exit 1 | ||
fi | ||
|
||
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then | ||
echo the $changelog is missing an \"Unreleased\" section | ||
exit 1 | ||
fi | ||
|
||
version=$(./scripts/eachdist.py version --package ${{ inputs.package }}) | ||
|
||
version_file=$(find $path -type f -path "*version*.py") | ||
file_count=$(echo "$version_file" | wc -l) | ||
|
||
if [ "$file_count" -ne 1 ]; then | ||
echo "Error: expected one version file, found $file_count" | ||
echo "$version_file" | ||
exit 1 | ||
fi | ||
|
||
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | ||
# 1.2.3 or 1.2.3rc1 | ||
major="${BASH_REMATCH[1]}" | ||
minor="${BASH_REMATCH[2]}" | ||
patch="${BASH_REMATCH[3]}" | ||
next_version="$major.$minor.$((patch + 1))" | ||
release_branch_name="package-release/${{ inputs.package }}/v$major.$minor.x" | ||
elif [[ $version =~ ^([0-9]+)\.([0-9]+)b([0-9]+)$ ]]; then | ||
# 0.1b1 | ||
major="${BASH_REMATCH[1]}" | ||
minor="${BASH_REMATCH[2]}" | ||
patch="${BASH_REMATCH[3]}" | ||
next_version="$major.${minor}b$((patch + 1))" | ||
release_branch_name="package-release/${{ inputs.package }}/v$major.${minor}bx" | ||
else | ||
echo "unexpected version: '$version'" | ||
exit 1 | ||
fi | ||
|
||
if [[ $GITHUB_REF_NAME != $release_branch_name ]]; then | ||
echo this workflow should only be run against $release_branch_name branch, but is running on $GITHUB_REF_NAME | ||
exit 1 | ||
fi | ||
|
||
echo "PACKAGE_NAME=${{ inputs.package }}" >> $GITHUB_ENV | ||
echo "VERSION=$version" >> $GITHUB_ENV | ||
echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV | ||
echo "CHANGELOG=$changelog" >> $GITHUB_ENV | ||
echo "VERSION_FILE=$version_file" >> $GITHUB_ENV | ||
|
||
- name: Update version | ||
run: | | ||
# replace the version in the version file (1.2.3 -> 1.2.4) | ||
sed -i -E "s/__version__\s*=\s*\"${VERSION}\"/__version__ = \"${NEXT_VERSION}\"/g" $VERSION_FILE | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
- name: Install tox | ||
run: pip install tox | ||
- name: run tox | ||
run: tox -e generate | ||
|
||
- name: Update the change log with the approximate release date | ||
run: | | ||
# the actual release date on main will be updated at the end of the release workflow | ||
date=$(date "+%Y-%m-%d") | ||
sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version ${NEXT_VERSION} ($date)/" ${CHANGELOG} | ||
|
||
- name: Use CLA approved github bot | ||
run: .github/scripts/use-cla-approved-github-bot.sh | ||
|
||
- name: Create pull request | ||
env: | ||
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | ||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
run: | | ||
message="Prepare patch release for ${PACKAGE_NAME} v${NEXT_VERSION}" | ||
branch="opentelemetrybot/patch-${PACKAGE_NAME}-version-to-v${NEXT_VERSION}" | ||
|
||
git commit -a -m "$message" | ||
git push origin HEAD:$branch | ||
gh pr create --title "[$GITHUB_REF_NAME] $message" \ | ||
--body "$message." \ | ||
--head $branch \ | ||
--base $GITHUB_REF_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
name: "[Package] Prepare release" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
package: | ||
type: choice | ||
options: | ||
- opentelemetry-propagator-aws-xray | ||
- opentelemetry-resource-detector-azure | ||
- opentelemetry-sdk-extension-aws | ||
lmolkova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: 'Package to be released' | ||
required: true | ||
|
||
jobs: | ||
prereqs: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.verify.outputs.version }} | ||
changelog: ${{ steps.verify.outputs.changelog }} | ||
version_file: ${{ steps.verify.outputs.version_file }} | ||
release_branch_name: ${{ steps.verify.outputs.release_branch_name }} | ||
next_version: ${{ steps.verify.outputs.next_version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: verify | ||
name: Verify prerequisites | ||
run: | | ||
if [[ $GITHUB_REF_NAME != main ]]; then | ||
echo this workflow should only be run against main | ||
exit 1 | ||
fi | ||
|
||
path=./$(./scripts/eachdist.py find-package --package ${{ inputs.package }}) | ||
changelog=$path/CHANGELOG.md | ||
|
||
if [ ! -f $changelog ]; then | ||
echo "missing $changelog file" | ||
exit 1 | ||
fi | ||
|
||
if ! grep --quiet "^## Unreleased$" $changelog; then | ||
echo the $changelog is missing an \"Unreleased\" section | ||
exit 1 | ||
fi | ||
|
||
version_dev=$(./scripts/eachdist.py version --package ${{ inputs.package }}) | ||
|
||
if [[ ! $version_dev =~ ^([0-9]+)\.([0-9]+)[\.|b]{1}([0-9]+).*.dev$ ]]; then | ||
echo "unexpected version: $version" | ||
exit 1 | ||
fi | ||
|
||
version=${version_dev%.dev} | ||
|
||
version_file=$(find $path -type f -path "*version*.py") | ||
file_count=$(echo "$version_file" | wc -l) | ||
|
||
if [ "$file_count" -ne 1 ]; then | ||
lmolkova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "Error: expected one version file, found $file_count" | ||
echo "$version_file" | ||
exit 1 | ||
fi | ||
|
||
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | ||
# 1.2.3 or 1.2.3rc1 | ||
major="${BASH_REMATCH[1]}" | ||
minor="${BASH_REMATCH[2]}" | ||
release_branch_name="package-release/${{ inputs.package }}/v$major.$minor.x" | ||
next_version="$major.$((minor + 1)).0" | ||
elif [[ $version =~ ^([0-9]+)\.([0-9]+)b([0-9]+)$ ]]; then | ||
# 0.1b1 | ||
major="${BASH_REMATCH[1]}" | ||
minor="${BASH_REMATCH[2]}" | ||
release_branch_name="package-release/${{ inputs.package }}/v$major.${minor}bx" | ||
next_version="$major.$((minor + 1))b0" | ||
else | ||
echo "unexpected version: '$version'" | ||
exit 1 | ||
fi | ||
|
||
echo "version=$version" >> $GITHUB_OUTPUT | ||
echo "changelog=$changelog" >> $GITHUB_OUTPUT | ||
echo "version_file=$version_file" >> $GITHUB_OUTPUT | ||
echo "release_branch_name=$release_branch_name" >> $GITHUB_OUTPUT | ||
echo "next_version=$next_version" >> $GITHUB_OUTPUT | ||
|
||
create-pull-request-against-release-branch: | ||
runs-on: ubuntu-latest | ||
needs: prereqs | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set environment variables | ||
run: | | ||
echo "RELEASE_BRANCH_NAME=${{ needs.prereqs.outputs.release_branch_name }}" >> $GITHUB_ENV | ||
echo "VERSION=${{ needs.prereqs.outputs.version }}" >> $GITHUB_ENV | ||
echo "CHANGELOG=${{ needs.prereqs.outputs.changelog }}" >> $GITHUB_ENV | ||
echo "VERSION_FILE=${{ needs.prereqs.outputs.version_file }}" >> $GITHUB_ENV | ||
echo "PACKAGE_NAME=${{ github.event.inputs.package }}" >> $GITHUB_ENV | ||
|
||
- name: Create package release branch | ||
run: | | ||
git push origin HEAD:$RELEASE_BRANCH_NAME | ||
|
||
- name: Update package version | ||
run: | | ||
# replace the version in the version file (1.2.3dev -> 1.2.3) | ||
sed -i -E "s/__version__\s*=\s*\"${VERSION}\.dev\"/__version__ = \"${VERSION}\"/g" $VERSION_FILE | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
- name: Install tox | ||
run: pip install tox | ||
- name: run tox | ||
run: tox -e generate | ||
|
||
- name: Update the change log with the approximate release date | ||
run: | | ||
date=$(date "+%Y-%m-%d") | ||
sed -Ei "s/^## Unreleased$/## Version ${VERSION} ($date)/" ${CHANGELOG} | ||
|
||
- name: Use CLA approved github bot | ||
run: .github/scripts/use-cla-approved-github-bot.sh | ||
|
||
- name: Create pull request against the release branch | ||
env: | ||
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | ||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
run: | | ||
message="Prepare release for ${PACKAGE_NAME} v${VERSION}" | ||
branch="opentelemetrybot/prepare-${RELEASE_BRANCH_NAME}" | ||
|
||
git commit -a -m "$message" | ||
git push origin HEAD:$branch | ||
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \ | ||
--body "$message." \ | ||
--head $branch \ | ||
--base $RELEASE_BRANCH_NAME | ||
|
||
create-pull-request-against-main: | ||
runs-on: ubuntu-latest | ||
needs: prereqs | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set environment variables | ||
run: | | ||
echo "PACKAGE_NAME=${{ github.event.inputs.package }}" >> $GITHUB_ENV | ||
echo "VERSION=${{ needs.prereqs.outputs.version }}" >> $GITHUB_ENV | ||
echo "VERSION_FILE=${{ needs.prereqs.outputs.version_file }}" >> $GITHUB_ENV | ||
echo "NEXT_VERSION=${{ needs.prereqs.outputs.next_version }}" >> $GITHUB_ENV | ||
echo "CHANGELOG=${{ needs.prereqs.outputs.changelog }}" >> $GITHUB_ENV | ||
|
||
- name: Update version | ||
run: | | ||
# replace the version in the version file (1.2.3dev -> 1.3.3.dev) | ||
sed -i -E "s/__version__\s*=\s*\"${VERSION}\.dev\"/__version__ = \"${NEXT_VERSION}.dev\"/g" $VERSION_FILE | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.9 | ||
- name: Install tox | ||
run: pip install tox | ||
- name: run tox | ||
run: tox -e generate | ||
|
||
- name: Update the change log on main | ||
run: | | ||
# the actual release date on main will be updated at the end of the release workflow | ||
date=$(date "+%Y-%m-%d") | ||
sed -Ei "s/^## Unreleased$/## Unreleased\n\n## Version ${VERSION} ($date)/" ${CHANGELOG} | ||
|
||
- name: Use CLA approved github bot | ||
run: .github/scripts/use-cla-approved-github-bot.sh | ||
|
||
- name: Create pull request against main | ||
env: | ||
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | ||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
run: | | ||
message="Update ${PACKAGE_NAME} version to v${NEXT_VERSION}" | ||
body="Update \`${PACKAGE_NAME}\` version to v\`${NEXT_VERSION}\`." | ||
branch="opentelemetrybot/update-${PACKAGE_NAME}-version-to-v${NEXT_VERSION}" | ||
|
||
git commit -a -m "$message" | ||
git push origin HEAD:$branch | ||
gh pr create --title "$message" \ | ||
--body "$body" \ | ||
--head $branch \ | ||
--base main |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.