Skip to content

Commit

Permalink
Merge pull request rook#8461 from subhamkrai/automate-release-action
Browse files Browse the repository at this point in the history
ci: create tag and print release notes
  • Loading branch information
travisn authored Aug 6, 2021
2 parents 91b7741 + 8572fdb commit 529ec0f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/create-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tag
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v1.7.0)'
required: true

defaults:
run:
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
shell: bash --noprofile --norc -eo pipefail -x {0}

jobs:
Create-Tag:
runs-on: ubuntu-18.04
if: {{ github.repository == 'rook/rook' }}
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: set env
run: |
echo "FROM_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "TO_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
echo "GITHUB_USER=rook" >> $GITHUB_ENV
- name: Create Tag
uses: negz/create-tag@v1
with:
version: ${{ github.event.inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get Release Note
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ env.GITHUB_USER }}
FROM_BRANCH: ${{ env.FROM_BRANCH }}
TO_TAG: ${{ env.TO_TAG }}
run: tests/scripts/gen_release_notes.sh
24 changes: 3 additions & 21 deletions tests/scripts/gen_release_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,14 @@ set -e

function help() {
print="
suppose we want release note for v1.6.8, we'll check the list of pr merged in upstream/release-1.6 but not present in v1.6.7
EXAMPLE command:
./tests/scripts/gen_release_notes.sh <rook/rook remote name>/release-1.6 v1.6.7
To run this command,
1. verify you are selecting right branch from GitHub UI dropdown menu
2. enter the tag you want to create
"
echo "$print"
exit 1
}

FROM_BRANCH=$1 # example branch name, "upstream/release-1.6"
TO_TAG=$2 # example tag, "v1.6.7"

if [[ $# -ne 2 ]]; then
echo "requires exactly 2 arguments"
help
fi

REMOTE=$(git remote show $(echo $1 | cut -d / -f1)|grep -oh $(echo $1 | cut -d / -f2-)|uniq >/dev/null 2>&1)
if ! $REMOTE ; then
echo "remote doesn't exist" $REMOTE
exit 1
fi

if ! git show-ref --tags $2 -q; then
echo "tag doesn't exist" $2
fi

if [ -z "${GITHUB_USER}" ] || [ -z "${GITHUB_TOKEN}" ]; then
echo "requires both GITHUB_USER and GITHUB_TOKEN to be set as env variable"
help
Expand Down

0 comments on commit 529ec0f

Please sign in to comment.