-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding workflow to create releases
- Loading branch information
1 parent
74f1b58
commit be47984
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
name: Create tag & release | ||
run-name: Create tag & release | ||
description: Create a new tag and release when a PR is merged to main (release/*) | ||
# yamllint disable-line rule:truthy | ||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: | ||
- main | ||
permissions: | ||
contents: write | ||
jobs: | ||
create_release: | ||
if: > | ||
github.event.pull_request.merged == true && | ||
github.event.pull_request.base.ref == 'main' && | ||
startsWith(github.event.pull_request.head.ref, 'release/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
- name: Get the version | ||
id: get_version | ||
run: | | ||
NEW_TAG=$(cat .version) | ||
PREVIOUS_TAG=$(git describe --tags --abbrev=0) | ||
echo "NEW_TAG=${NEW_TAG}" >> ${GITHUB_ENV} | ||
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> ${GITHUB_ENV} | ||
- name: Create the new tag | ||
id: create_tag | ||
run: | | ||
git config --global user.email "release-bot@open-metadata.org" | ||
git config --global user.name "OpenMetadata Release Bot" | ||
git tag -a ${{ env.NEW_TAG }} -m "Release version ${{ env.NEW_TAG }}" | ||
git push origin ${{ env.NEW_TAG }} | ||
- name: Create the release body | ||
id: create_release_body | ||
run: | | ||
function create_release_body() { | ||
if [[ $# -ne 3 ]]; then | ||
echo "Usage: create_release_body <previous_tag> <new_tag> <repo_url>" | ||
return 1 | ||
fi | ||
local PREVIOUS_TAG=${1} | ||
local NEW_TAG=${2} | ||
local REPO_URL=${3} | ||
local DATE=$(date +%Y-%m-%d) | ||
local RELEASE_BODY_FILE="/tmp/body.md" | ||
local REPO_URL="https://github.com/${{ github.repository }}" | ||
cat > ${RELEASE_BODY_FILE} <<-EOF | ||
## [${NEW_TAG}](${REPO_URL}/compare/${PREVIOUS_TAG}...${NEW_TAG}) (${DATE}) | ||
### Features | ||
* Bump OpenMetadata version to ${NEW_TAG} | ||
EOF | ||
cat ${RELEASE_BODY_FILE} | ||
echo "RELEASE_BODY_FILE=${RELEASE_BODY_FILE}" >> ${GITHUB_ENV} | ||
} | ||
create_release_body "${{ env.PREVIOUS_TAG}}" "${{ env.NEW_TAG }}" "${{ env.REPO_URL }}" | ||
- name: Create the new release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ env.NEW_TAG }} | ||
body_path: ${{ env.RELEASE_BODY_FILE }} |