Skip to content

Commit

Permalink
introduce a github action for open source release (#5732)
Browse files Browse the repository at this point in the history
* introduce a github action for open source release

* add more-secrets environment

* PR body should contain the changelog

* update script

* add new lines
  • Loading branch information
subodh1810 authored Aug 31, 2021
1 parent bba0afe commit 3260a48
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
current_version = 0.29.13-alpha
commit = True
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-[a-z]+)?
serialize =
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/release-airbyte-os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release Open Source Airbyte
on:
workflow_dispatch:
inputs:
partToBump:
description: "Please choose the type of version upgrade : major|minor|patch"
required: true
default: "patch"
jobs:
releaseAirbyte:
runs-on: ubuntu-latest
environment: more-secrets
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Save Old Version
id: old_version
run: |
echo ::set-output name=OLD_VERSION::$(grep VERSION .env | cut -d"=" -f2)
- name: Release Airbyte
id: release_airbyte
env:
PART_TO_BUMP: ${{ github.event.inputs.partToBump }}
CLOUDREPO_USER: ${{ secrets.CLOUDREPO_USER }}
CLOUDREPO_PASSWORD: ${{ secrets.CLOUDREPO_PASSWORD }}
run: |
docker login -u airbytebot -p ${{ secrets.DOCKER_PASSWORD }}
./tools/bin/release_version.sh
- name: Save New Version
id: new_version
run: |
echo ::set-output name=NEW_VERSION::$(grep VERSION .env | cut -d"=" -f2)
- name: Get PR Body
id: pr_body
env:
PREV_VERSION: ${{ steps.old_version.outputs.OLD_VERSION }}
run: |
chmod +x tools/bin/pr_body.sh
body=$(./tools/bin/pr_body.sh)
body="${body//$'\n'/'%0A'}"
echo ::set-output name=PR_BODY::$body
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.SLASH_COMMAND_PAT }}
branch: bump-version
branch-suffix: random
delete-branch: true
title: Bump Airbyte version from ${{ steps.old_version.outputs.OLD_VERSION }} to ${{ steps.new_version.outputs.NEW_VERSION }}
body: ${{ steps.pr_body.outputs.PR_BODY }}
commit-message: Bump Airbyte version from ${{ steps.old_version.outputs.OLD_VERSION }} to ${{ steps.new_version.outputs.NEW_VERSION }}
- name: PR Details
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
17 changes: 17 additions & 0 deletions tools/bin/pr_body.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

. tools/lib/lib.sh

GIT_REVISION=$(git rev-parse HEAD)
[[ -z "$GIT_REVISION" ]] && echo "Couldn't get the git revision..." && exit 1

echo "Changelog:"
echo
PAGER=cat git log v${PREV_VERSION}..${GIT_REVISION} --oneline --decorate=no
echo
echo "Steps After Merging PR:"
echo "1. Pull most recent version of master"
echo "2. Run ./tools/bin/tag_version.sh"
echo "3. Create a GitHub release with the changelog"
20 changes: 0 additions & 20 deletions tools/bin/release_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ set -e

. tools/lib/lib.sh

BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ "$BRANCH" == "master" ]]; then
echo 'This script should be run from a branch!';
exit 1;
fi

if [[ -z "${CLOUDREPO_USER}" ]]; then
echo 'CLOUDREPO_USER env var not set. Please retrieve the user email from the CloudRepo lastpass secret and run export CLOUDREPO_USER=<user_from_secret>.';
exit 1;
Expand All @@ -23,7 +16,6 @@ fi

PREV_VERSION=$(grep VERSION .env | cut -d"=" -f2)

PART_TO_BUMP=$1
[[ -z "$PART_TO_BUMP" ]] && echo "Usage ./tools/bin/release_version.sh (major|minor|patch)" && exit 1

# uses .bumpversion.cfg to find files to bump
Expand All @@ -44,15 +36,3 @@ SUB_BUILD=PLATFORM ./gradlew publish
VERSION=$NEW_VERSION GIT_REVISION=$GIT_REVISION docker-compose -f docker-compose.build.yaml build
VERSION=$NEW_VERSION GIT_REVISION=$GIT_REVISION docker-compose -f docker-compose.build.yaml push
echo "Completed building and publishing..."

echo
echo "Changelog:"
PAGER=cat git log v${PREV_VERSION}..${GIT_REVISION} --oneline --decorate=no

echo
echo "Final Steps:"
echo "1. Push your changes"
echo "2. Merge your PR"
echo "3. Switch to master"
echo "4. Run ./tools/bin/tag_version.sh"
echo "5. Create a GitHub release with the changelog"

0 comments on commit 3260a48

Please sign in to comment.