Skip to content

Commit

Permalink
Revert "fix: release flow (#108)"
Browse files Browse the repository at this point in the history
This reverts commit 5345f85.
  • Loading branch information
sanpj2292 authored Mar 20, 2024
1 parent 5345f85 commit 5171def
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 97 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/create-hotfix-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Create New Hotfix Branch

on:
workflow_dispatch:
inputs:
hotfix_name:
description: Hotfix branch name
required: true

jobs:
create-branch:
name: Create New Hotfix Branch
runs-on: ubuntu-latest

# Only allow these users to create new hotfix branch from 'main'
if: github.ref == 'refs/heads/main' && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'utsabc' || github.actor == 'shrouti1507') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'shrouti1507' || github.triggering_actor == 'utsabc')
steps:
- name: Create Branch
uses: peterjgrainger/action-create-branch@v2.4.0
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
branch: 'hotfix/${{ inputs.hotfix_name }}'
88 changes: 88 additions & 0 deletions .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Draft New Release

on: workflow_dispatch

jobs:
draft-new-release:
name: Draft New Release
runs-on: ubuntu-latest

# Only allow release stakeholders to initiate releases
if: (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')) && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'utsabc' || github.actor == 'shrouti1507') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'utsabc' || github.triggering_actor == 'shrouti1507')
steps:
- name: Checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4.0.1
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Dependencies
env:
HUSKY: 0
run: |
npm ci
# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize Mandatory Git Config
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "noreply@github.com"
# Calculate the next release version based on conventional semantic release
- name: Create Release Branch
id: create-release
env:
HUSKY: 0
run: |
source_branch_name=${GITHUB_REF##*/}
release_type=release
grep -q "hotfix/" <<< "${GITHUB_REF}" && release_type=hotfix-release
git fetch origin main
git fetch --tags origin
git merge origin/main
current_version=$(jq -r .version package.json)
npm run release -- --skip.commit --skip.tag --skip.changelog
new_version=$(jq -r .version package.json)
git reset --hard
branch_name="${release_type}/v${new_version}"
echo "Source branch for new release is $source_branch_name"
echo "Current version is $current_version"
echo "Release type is $release_type"
echo "New version is $new_version"
echo "New release branch name is $branch_name"
git checkout -b "$branch_name"
git push --set-upstream origin "$branch_name"
echo "source_branch_name=$source_branch_name" >> $GITHUB_OUTPUT
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "NEW_VERSION_VALUE=$new_version" >> $GITHUB_ENV
- name: Update Changelog & Bump Version
id: finish-release
env:
HUSKY: 0
run: |
echo "Current version: $CURRENT_VERSION_VALUE"
echo "New version: $NEW_VERSION_VALUE"
npm run release -- -a --skip.tag --no-verify
git push
- name: Create Pull Request
uses: repo-sync/pull-request@v2.12.1
with:
source_branch: ${{ steps.create-release.outputs.branch_name }}
destination_branch: 'main'
github_token: ${{ secrets.PAT }}
pr_title: 'chore(release): pull ${{ steps.create-release.outputs.branch_name }} into main'
pr_body: ':crown: *An automated PR*'
20 changes: 10 additions & 10 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: Docker Image CI for shopify-tracker
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
PAT:
required: true
description: Personal access token to be used for cloning rudder-devops
push:
branches: [main]
pull_request:
types:
- closed
branches:
- main

permissions: read-all

jobs:
extract-version:
name: Extract Version
runs-on: ubuntu-latest
if: ((startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true)
outputs:
version: ${{ steps.get-version.outputs.version }}

Expand All @@ -29,11 +28,12 @@ jobs:
id: get-version
run: |
version=$(jq -r .version package.json)
echo "Version: $version"
echo "Version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
build:
name: Build Shopify Tracker Docker Image
if: ((startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true)
needs: [extract-version]
uses: ./.github/workflows/build-and-push-docker-image.yml
with:
Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Publish New GitHub Release

on:
pull_request:
types:
- closed
branches:
- main

jobs:
release:
name: Publish New GitHub Release
runs-on: ubuntu-latest

if: (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true # only merged pull requests must trigger this job

steps:
- name: Extract Version
id: extract-version
run: |
branch_name="${{ github.event.pull_request.head.ref }}"
version=${branch_name#hotfix-}
version=${version#release/v}
echo "release_version=$version" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4.1.0
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4.0.1
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Dependencies
env:
HUSKY: 0
run: |
npm ci
# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize Mandatory Git Config
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "noreply@github.com"
- name: Tag & Create GitHub Release
id: create_release
env:
HUSKY: 0
GITHUB_TOKEN: ${{ secrets.PAT }}
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ secrets.PAT }}
run: |
git fetch --tags origin
git tag -a v${{ steps.extract-version.outputs.release_version }} -m "chore: release v${{ steps.extract-version.outputs.release_version }}"
git push origin refs/tags/v${{ steps.extract-version.outputs.release_version }}
npm run release:github
echo "DATE=$(date)" >> $GITHUB_ENV
- name: Pull Changes Into develop Branch
uses: repo-sync/pull-request@v2.12.1
with:
source_branch: 'main'
destination_branch: 'develop'
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: 'chore(release): pull main into develop post release v${{ steps.extract-version.outputs.release_version }}'
pr_body: ':crown: *An automated PR*'

- name: Delete Release Branch
uses: koj-co/delete-merged-action@master
if: startsWith(github.event.pull_request.head.ref, 'release/')
with:
branches: 'release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete Hotfix Release Branch
uses: koj-co/delete-merged-action@master
if: startsWith(github.event.pull_request.head.ref, 'hotfix-release/')
with:
branches: 'hotfix-release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Notify Slack Channel
id: slack
uses: slackapi/slack-github-action@v1.24.0
continue-on-error: true
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
PROJECT_NAME: 'Rudder Shopify Tracker'
RELEASES_URL: 'https://github.com/rudderlabs/rudder-shopify-tracker/releases/tag/'
with:
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}
payload: |
{
"text": "*<${{env.RELEASES_URL}}v${{ steps.extract-version.outputs.release_version }}|v${{ steps.extract-version.outputs.release_version }}>*\nCC: <@U03KG4BK1L1> <@U01LVJ30QEB> <@U01FG952S8Y>",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":tada: ${{ env.PROJECT_NAME }} - New GitHub Release :tada:"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*<${{env.RELEASES_URL}}v${{ steps.extract-version.outputs.release_version }}|v${{ steps.extract-version.outputs.release_version }}>*\nCC: <@U03KG4BK1L1> <@U01LVJ30QEB> <@U01FG952S8Y>"
}
}
]
}
87 changes: 0 additions & 87 deletions .github/workflows/release-please.yml

This file was deleted.

0 comments on commit 5171def

Please sign in to comment.