Skip to content

release: v0.52.0

release: v0.52.0 #21

Workflow file for this run

name: Test
on:
push:
branches:
- main
- 'release/v*'
jobs:
release-tag:
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message, 'release:') }}
steps:
# Since skip-github-release is specified, the outputs of googleapis/release-please-action cannot be used.
# Therefore, we need to parse the version ourselves.
- name: Extract version and PR number from commit message
id: extract_info
shell: bash
run: |
echo "version=$( echo "${{ github.event.head_commit.message }}" | sed 's/^release: v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT
echo "pr_number=$( echo "${{ github.event.head_commit.message }}" | sed 's/.*(\#\([0-9]\+\)).*$/\1/' )" >> $GITHUB_OUTPUT
echo "release_branch=release/v$( echo "${{ github.event.head_commit.message }}" | sed 's/^release: v\([0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT
# When v0.50.0 is released, a release branch "release/v0.50" is created.
- name: Add release branch to rulesets
if: ${{ endsWith(steps.extract_info.outputs.version, '.0') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
RULESET_ID=$(gh api /repos/${{ github.repository }}/rulesets --jq '.[] | select(.name=="release") | .id')
echo "$RULESET_ID"
echo ${{ steps.extract_info.outputs.version }}
echo ${{ steps.extract_info.outputs.release_branch }}
NEW_BRANCHES=$(gh api /repos/${{ github.repository }}/rulesets/$RULESET_ID | jq '{conditions}' | jq '.conditions.ref_name.include += ["${{ steps.extract_info.outputs.release_branch }}"]')
echo "$NEW_BRANCHES"
echo "$NEW_BRANCHES" | gh api --method put --input - /repos/${{ github.repository }}/rulesets/$RULESET_ID