From 69d13a80473b717c9e407845ecae92d86adfded0 Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Wed, 12 Jun 2024 13:21:55 +0400 Subject: [PATCH 1/2] feat(.github): tune release commit flow --- .github/workflows/release-commit.yml | 37 ++++++++++++---------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release-commit.yml b/.github/workflows/release-commit.yml index 8f7327c34..ddc87cd69 100644 --- a/.github/workflows/release-commit.yml +++ b/.github/workflows/release-commit.yml @@ -4,19 +4,23 @@ 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 @@ -24,21 +28,6 @@ jobs: - 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 @@ -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 }} From e4f9972f605c1cbf80ce994366a51670b5ac28c9 Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Wed, 12 Jun 2024 13:22:41 +0400 Subject: [PATCH 2/2] feat(.github): tune release publish flow --- .github/workflows/release-publish.yml | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 6a20b948b..146c77c87 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -5,25 +5,12 @@ on: - release jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - run: npm ci - - run: npm test - - publish-npm: - needs: build + release-publish-npm: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - with: - ref: main - + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -33,6 +20,12 @@ jobs: - name: Install dependencies run: npm ci + - name: Run unit tests + run: npm test + + - name: Install dependencies + run: npm ci + - name: Initialize git user email run: git config --global user.email "${{ env.RELEASE_USER_EMAIL }}" @@ -60,6 +53,11 @@ jobs: echo "LATEST_RELEASE_NAME=$LATEST_RELEASE_NAME" >> $GITHUB_ENV echo "IS_PRE_RELEASE=$IS_PRE_RELEASE" >> $GITHUB_ENV + - name: Fetch and checkout to release branch + run: | + git fetch --all + git checkout ${{ vars.RELEASE_BRANCH_NAME }} + - name: Publish to npm (pre-release) if: env.IS_PRE_RELEASE == 'true' run: npm publish --tag beta