Skip to content

Commit

Permalink
Add release_pr.sh, simplify version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Jan 19, 2024
1 parent fe209e3 commit 4c3b3a1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
36 changes: 36 additions & 0 deletions .github/scripts/release_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# © 2024 SolarWinds Worldwide, LLC. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

# input release version number, e.g. 1.1.0
version_number="$1"

branch_name="release/rel-${version_number}"

# Create release branch
echo "Creating new branch '$branch_name' from 'main'"
gh api -X POST /repos/solarwinds/apm-python/git/refs \
--field ref="refs/heads/$branch_name" \
--field sha="$(git rev-parse "origin/main")"

# Get SHA of current version.py at main
SHA=$(gh api /repos/solarwinds/apm-python/contents/solarwinds_apm/version.py?ref="main" --jq '.sha')

# Commit version.py with updated agent version
echo "Pushing new version.py to branch '$branch_name'"
gh api --method PUT /repos/solarwinds/apm-python/contents/solarwinds_apm/version.py \
--field message="Update agent version to $version_number" \
--field content="__version__ = '$version_number'" \
--field encoding="base64" \
--field branch="$branch_name" \
--field sha="$SHA"

# Open draft Pull Request for version bump
echo "Creating draft pull request"
gh pr create --draft --base "main" --head "$branch_name" \
--title "solarwinds-apm $version_number" \
--body "For PyPI release of solarwinds-apm $version_number. See also CHANGELOG.md."
22 changes: 2 additions & 20 deletions .github/workflows/create_release_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,7 @@ jobs:
echo "FATAL ERROR: Release tag ${{ env.RELEASE_NAME }} already exists!"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release branch
run: git checkout -b release/${{ env.RELEASE_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update agent version
run: sed -i -e "s/^__version__ = \".*\"$/__version__ = \"${{ env.RELEASE_VERSION }}\"/" solarwinds_apm/version.py
- name: Commit version.py
run: |
git add solarwinds_apm/version.py
git commit --message "Update agent version to ${{ env.RELEASE_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push new release branch to remote repositories
run: git push origin release/${{ env.RELEASE_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Open draft Pull Request for version bump
run: gh pr create --draft --title "solarwinds-apm ${{ env.RELEASE_VERSION }}" --body "For PyPI release of solarwinds-apm ${{ env.RELEASE_VERSION }}. See also CHANGELOG.md."
- name: Create release branch draft pull request
run: cd .github/scripts && ./release_pr.sh ${{ env.RELEASE_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 1 addition & 8 deletions solarwinds_apm/version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
# © 2023 SolarWinds Worldwide, LLC. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

"""Version of SolarWinds Custom-Distro for OpenTelemetry agents"""
__version__ = "1.1.0"
__version__ = "1.1.0"

0 comments on commit 4c3b3a1

Please sign in to comment.