Skip to content

Commit

Permalink
feat(.github): tune release commit flow
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Jun 12, 2024
1 parent 71cc131 commit 69d13a8
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions .github/workflows/release-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,30 @@ on:
types: [published]

env:
PR_BRANCH_NAME: release-${{github.event.release.tag_name}}
PR_BRANCH_NAME: release-${{ github.event.release.tag_name }}
PRE_RELEASE: ${{ github.event.release.prerelease}}

jobs:
build:
release-commit-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm test

create-release-commit:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: npm ci

Expand All @@ -48,19 +37,25 @@ jobs:
- name: Initialize git user name
run: git config --global user.name "Release commit workflow"

- name: Create release branch
- name: Fetch latest changes
run: git fetch --all

- name: Checkout to release branch if it's not a pre-release
if: ${{!env.PRE_RELEASE}}
run: git checkout ${{ vars.RELEASE_BRANCH_NAME }}

- name: Checkout to current release branch to create PR from
run: |
git checkout -b $PR_BRANCH_NAME
git push --set-upstream origin $PR_BRANCH_NAME
echo "branch=$PR_BRANCH_NAME" >> $GITHUB_ENV
- name: Bump version and push changes using release-it
run: |
npm run release -- --ci ${{github.event.release.tag_name}}
npm run release -- --ci ${{ github.event.release.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create pull request
run: gh pr create -B release -H $PR_BRANCH_NAME --title "Release ${{github.event.release.tag_name}}" --body "${{github.event.release.body}}"
run: gh pr create -B ${{ vars.RELEASE_BRANCH_NAME }} -H $PR_BRANCH_NAME --title "Release ${{github.event.release.tag_name}}" --body "${{github.event.release.body}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 69d13a8

Please sign in to comment.