Skip to content

[minor] Release v1.8.0 (#98) #11

[minor] Release v1.8.0 (#98)

[minor] Release v1.8.0 (#98) #11

#
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# 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
#
# https://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.
#
name: "Run [major/minor] Release"
on:
push:
branches:
- "main"
env:
BACKPORT_LABEL_PREFIX: "actions/backport/"
jobs:
dump-contexts-to-log:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/dump-context
semver-auto:
runs-on: ubuntu-latest
needs: [dump-contexts-to-log]
outputs:
RELEASE_BRANCH_NAME: ${{ steps.upgrade_semver.outputs.RELEASE_BRANCH_NAME }}
RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }}
RELEASE: ${{ steps.setup_for_release.outputs.RELEASE }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.DISPATCH_TOKEN }}
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Set context
id: set_context
run: |
LATEST_TAG=`git tag --sort=v:refname | tail -n 1`
UNSUPPORTED_VERSION=`git tag --sort=v:refname | sed -E 's/^v([0-9]+\.[0-9]+).*$/v\1/' | uniq | tail -n 2 | head -n 1`
RELEASE_KIND=`echo "${{ github.event.head_commit.message }}" | sed -n -E 's:^\[(major|minor)\].*:\1:p'`
echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_OUTPUT # e.g) v1.7.6
echo "RELEASE_KIND=${RELEASE_KIND}" >> $GITHUB_OUTPUT # e.g) major or minor
echo "UNSUPPORTED_VERSION=${UNSUPPORTED_VERSION}" >> $GITHUB_OUTPUT # e.g) v1.6
echo "LATEST_TAG=${LATEST_TAG}"
echo "RELEASE_KIND=${RELEASE_KIND}"
echo "UNSUPPORTED_VERSION=${UNSUPPORTED_VERSION}"
- name: Upgrade semver
id: upgrade_semver
if: ${{ steps.set_context.outputs.RELEASE_KIND != '' }}
env:
LATEST_TAG: ${{ steps.set_context.outputs.LATEST_TAG }}
RELEASE_KIND: ${{ steps.set_context.outputs.RELEASE_KIND }}
run: |
IFS=. read -r version minor patch <<< `echo "${LATEST_TAG}" | sed -e 's:^v::'` # e.g) version=1, minor=7, patch=7
case ${RELEASE_KIND} in
major) RELEASE_TAG="v$((version+1)).0.0"; RELEASE_BRANCH_NAME="release/v$((version+1)).0"; ;;
minor) RELEASE_TAG="v$version.$((minor+1)).0"; RELEASE_BRANCH_NAME="release/v$version.$((minor+1))"; ;;
*) echo "no need to update"; exit 0; ;;
esac
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_OUTPUT
echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=${RELEASE_TAG}"
echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}"
- name: Setup for release
id: setup_for_release
if: ${{ steps.upgrade_semver.outputs.RELEASE_TAG != '' }}
env:
RELEASE_TAG: ${{ steps.upgrade_semver.outputs.RELEASE_TAG }}
RELEASE_BRANCH_NAME: ${{ steps.upgrade_semver.outputs.RELEASE_BRANCH_NAME }}
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
run: |
git checkout -b ${RELEASE_BRANCH_NAME} && git push origin ${RELEASE_BRANCH_NAME}
gh label create "${BACKPORT_LABEL_PREFIX}${RELEASE_BRANCH_NAME}" # e.g) actions/backport/release/v1.8
echo "RELEASE=true" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=${RELEASE_TAG}"
echo "RELEASE_BRANCH_NAME=${RELEASE_BRANCH_NAME}"
echo "LABEL_NAME=${BACKPORT_LABEL_PREFIX}${RELEASE_BRANCH_NAME}"
release-pr:
if: ${{ needs.semver-auto.outputs.RELEASE == 'true' }}
needs:
- semver-auto
uses: ./.github/workflows/_release-pr.yml
with:
release_branch_name: ${{ needs.semver-auto.outputs.RELEASE_BRANCH_NAME }}
release_tag: ${{ needs.semver-auto.outputs.RELEASE_TAG }}
secrets: inherit