Add permissions that were missed on the first pass #11
Workflow file for this run
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
name: Prepare patch release | ||
on: | ||
workflow_dispatch: | ||
permissions: | ||
contents: read | ||
jobs: | ||
prepare-patch-release: | ||
permissions: | ||
contents: write # required for pushing branches | ||
pull-requests: write # required for creating and editing pull requests | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # required for pushing changes | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
if [[ ! $GITHUB_REF_NAME =~ ^release/v[0-9]+\.[0-9]+\.x-0\.[0-9]+bx$ ]]; then | ||
echo this workflow should only be run against long-term release branches | ||
exit 1 | ||
fi | ||
if ! grep --quiet "^## Unreleased$" CHANGELOG.md; then | ||
echo the change log is missing an \"Unreleased\" section | ||
exit 1 | ||
fi | ||
- name: Set environment variables | ||
run: | | ||
stable_version=$(./scripts/eachdist.py version --mode stable) | ||
unstable_version=$(./scripts/eachdist.py version --mode prerelease) | ||
if [[ $stable_version =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then | ||
stable_major_minor="${BASH_REMATCH[1]}" | ||
stable_patch="${BASH_REMATCH[2]}" | ||
else | ||
echo "unexpected stable_version: $stable_version" | ||
exit 1 | ||
fi | ||
if [[ $unstable_version =~ ^0\.([0-9]+)b([0-9]+)$ ]]; then | ||
unstable_minor="${BASH_REMATCH[1]}" | ||
unstable_patch="${BASH_REMATCH[2]}" | ||
else | ||
echo "unexpected unstable_version: $unstable_version" | ||
exit 1 | ||
fi | ||
stable_version_prev="$stable_major_minor.$((stable_patch))" | ||
unstable_version_prev="0.${unstable_minor}b$((unstable_patch))" | ||
stable_version="$stable_major_minor.$((stable_patch + 1))" | ||
unstable_version="0.${unstable_minor}b$((unstable_patch + 1))" | ||
echo "STABLE_VERSION=$stable_version" >> $GITHUB_ENV | ||
echo "UNSTABLE_VERSION=$unstable_version" >> $GITHUB_ENV | ||
echo "STABLE_VERSION_PREV=$stable_version_prev" >> $GITHUB_ENV | ||
echo "UNSTABLE_VERSION_PREV=$unstable_version_prev" >> $GITHUB_ENV | ||
- name: Update version | ||
run: .github/scripts/update-version-patch.sh $STABLE_VERSION $UNSTABLE_VERSION $STABLE_VERSION_PREV $UNSTABLE_VERSION_PREV | ||
- 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 ${STABLE_VERSION}\/${UNSTABLE_VERSION} ($date)/" CHANGELOG.md | ||
- name: Use CLA approved github bot | ||
run: .github/scripts/use-cla-approved-github-bot.sh | ||
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 | ||
id: otelbot-token | ||
with: | ||
app-id: ${{ vars.OTELBOT_APP_ID }} | ||
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} | ||
- name: Create pull request | ||
id: create_pr | ||
env: | ||
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | ||
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }} | ||
run: | | ||
message="Prepare release ${STABLE_VERSION}/${UNSTABLE_VERSION}" | ||
branch="otelbot/prepare-release-${STABLE_VERSION}-${UNSTABLE_VERSION}" | ||
git commit -a -m "$message" | ||
git push origin HEAD:$branch | ||
pr_url=$(gh pr create --title "[$GITHUB_REF_NAME] $message" \ | ||
--body "$message." \ | ||
--head $branch \ | ||
--base $GITHUB_REF_NAME) | ||
echo "pr_url=$pr_url" >> $GITHUB_OUTPUT | ||
- name: Add prepare-release label to PR | ||
if: steps.create_pr.outputs.pr_url != '' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh pr edit ${{ steps.create_pr.outputs.pr_url }} --add-label "prepare-release" |