From fce58a206bed252add984349c95dee838e387dcc Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:38:13 +0530 Subject: [PATCH 1/8] refactor: update lint and test pipelines --- .github/workflows/lint.yml | 8 ++++---- .github/workflows/test.yml | 29 ++++++++--------------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 47befa8..1e5b938 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,14 +8,14 @@ on: jobs: lint: name: Lint - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 20 - name: Install dependencies run: yarn diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87d7db3..3b9d8d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,34 +9,21 @@ jobs: name: Test runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20 - name: Install dependencies run: yarn - - name: Run test over the merged changes - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - git checkout $GITHUB_BASE_REF - git merge --no-commit --no-edit ${{ github.event.pull_request.head.sha }} - yarn - yarn lerna run build - yarn test - if: github.event_name == 'pull_request' + - name: Run build + run: yarn lerna run build - - name: Test - run: | - yarn lerna run build - yarn test - if: github.event_name != 'pull_request' + - name: Run test + run: yarn test - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 \ No newline at end of file + uses: codecov/codecov-action@v3 From 432e1dca17e13b2b7fb900198cf7fc06dfef6bca Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Mon, 7 Oct 2024 19:19:25 +0530 Subject: [PATCH 2/8] fix: use node-version 20.x instead of 20 --- .github/workflows/lint.yml | 5 ++--- .github/workflows/test.yml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1e5b938..45a92d5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,9 +1,8 @@ name: Lints on: + push: pull_request: - branches: - - main jobs: lint: @@ -15,7 +14,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 20 + node-version: '20.x' - name: Install dependencies run: yarn diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b9d8d5..ac0c700 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 20 + node-version: '20.x' - name: Install dependencies run: yarn From 8044e98f6990a5544affaf29139651b841d740d7 Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Mon, 7 Oct 2024 19:19:48 +0530 Subject: [PATCH 3/8] feat: add release pipeline --- .github/workflows/release.yml | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 879006d..c71dc95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,38 +1,36 @@ name: Release on: - push: - branches: - - main workflow_run: - workflows: ['Lints', 'Coverage'] + workflows: ['Test'] types: - completed + branches: + - main concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: name: Release - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 - cache: 'yarn' - cache-dependency-path: '**/yarn.lock' - - - uses: actions/setup-node@v1 - with: - node-version: 16 + node-version: '20.x' registry-url: 'https://registry.npmjs.org' - - name: Config git user - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - run: yarn install --frozen-lockfile + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run build + run: yarn lerna run build + + - name: Publish to NPM + run: yarn lerna publish --yes --no-private + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From d0c6e5732ad191e5f45bc6ccf9a13c03997b303b Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:36:23 +0530 Subject: [PATCH 4/8] fix: Fix release pipeline --- .github/workflows/release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c71dc95..c7972c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,12 @@ jobs: - name: Run build run: yarn lerna run build + - name: Bump package versions + run: yarn lerna version --yes --conventional-commits --exact --create-release github --loglevel silly + env: + GH_TOKEN: ${{ github.token }} + - name: Publish to NPM - run: yarn lerna publish --yes --no-private + run: yarn lerna publish from-package --yes --no-private --loglevel silly env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From fa4b66b5bbb9da5fdfab4689daf3122b19c825b1 Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Fri, 11 Oct 2024 17:11:01 +0530 Subject: [PATCH 5/8] chore: add support for beta releases through pipeline --- .github/workflows/lint.yml | 1 - .github/workflows/release.yml | 29 +++++++++++++++++++++-------- .github/workflows/test.yml | 1 - 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 45a92d5..c90a64c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,6 @@ name: Lints on: - push: pull_request: jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7972c3..f531c9e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,10 @@ name: Release on: - workflow_run: - workflows: ['Test'] - types: - - completed + push: branches: - main + - development concurrency: ${{ github.workflow }}-${{ github.ref }} @@ -14,6 +12,8 @@ jobs: release: name: Release runs-on: ubuntu-22.04 + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@v4 @@ -30,12 +30,25 @@ jobs: - name: Run build run: yarn lerna run build - - name: Bump package versions - run: yarn lerna version --yes --conventional-commits --exact --create-release github --loglevel silly + - name: Run test + run: yarn test + + - name: Bump version and create release + run: | + if [ "${{ github.ref_name }}" == "development" ]; then + yarn lerna version --yes --conventional-commits --conventional-prerelease --exact --create-release github --loglevel silly + else + yarn lerna version --yes --conventional-commits --exact --create-release github --loglevel silly + fi env: GH_TOKEN: ${{ github.token }} - name: Publish to NPM - run: yarn lerna publish from-package --yes --no-private --loglevel silly + run: | + if [ "${{ github.ref_name }}" == "development" ]; then + yarn lerna publish from-package --yes --no-private --loglevel silly --preid beta --dist-tag beta + else + yarn lerna publish from-package --yes --no-private --loglevel silly + fi env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac0c700..f8806ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,6 @@ name: Test on: - push: pull_request: jobs: From 8a0cae2e80b1e508f06f5d0d9fab0594a270e790 Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:05:08 +0530 Subject: [PATCH 6/8] fix: publish pipeline flow --- .github/workflows/release.yml | 11 ++++++-- .github/workflows/sync-dev-branch.yml | 38 +++++++++++++++++++++++++++ lerna.json | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/sync-dev-branch.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f531c9e..4f8d2c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,8 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: name: Release + # Skip if [ci publish] is in the commit message + if: ${{ !contains(github.event.head_commit.message, '[ci publish]') }} runs-on: ubuntu-22.04 permissions: contents: write @@ -33,12 +35,17 @@ jobs: - name: Run test run: yarn test + - name: Configure git user + run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + - name: Bump version and create release run: | if [ "${{ github.ref_name }}" == "development" ]; then - yarn lerna version --yes --conventional-commits --conventional-prerelease --exact --create-release github --loglevel silly + yarn lerna version --yes --conventional-commits --conventional-prerelease --exact --create-release github --preid beta --loglevel silly else - yarn lerna version --yes --conventional-commits --exact --create-release github --loglevel silly + yarn lerna version --yes --conventional-commits --conventional-graduate --exact --create-release github --loglevel silly fi env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/sync-dev-branch.yml b/.github/workflows/sync-dev-branch.yml new file mode 100644 index 0000000..8fbb0ff --- /dev/null +++ b/.github/workflows/sync-dev-branch.yml @@ -0,0 +1,38 @@ +name: Sync development with main + +on: + push: + branches: + - main + +jobs: + sync-development: + runs-on: ubuntu-22.04 + permissions: + contents: read + pull-requests: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Create pull request to development + env: + GH_TOKEN: ${{ github.token }} + run: | + # Check if a pull request already exists from main to development + pr_url=$(gh pr list --head main --base development --json url --jq '.[0].url') + + if [ -n "$pr_url" ]; then + echo "PR already exists: $pr_url" + else + pr_url=$(gh pr create \ + --base development \ + --head main \ + --title "[skip ci] Sync development with main" \ + --body "Auto-created pull request to merge changes from main into development." + ) + echo "Created PR: $pr_url" + fi + + # Attempt to merge the pull request (Fails, investigate later) + # gh pr merge "$pr_url" --merge --auto \ No newline at end of file diff --git a/lerna.json b/lerna.json index 38dcea9..2c9ae56 100644 --- a/lerna.json +++ b/lerna.json @@ -6,7 +6,7 @@ "command": { "version": { "message": "chore(release): Publish 🚀 [ci publish]", - "allowBranch": ["main"], + "allowBranch": ["main", "development"], "conventional-commits": true, "create-release": "github" } From 05b97345d3f43787d24c11e6a6ec79bb0af0abb4 Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:14:10 +0530 Subject: [PATCH 7/8] chore: use skip ci magic string --- .github/workflows/release.yml | 2 -- lerna.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f8d2c6..d374f5e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,6 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: name: Release - # Skip if [ci publish] is in the commit message - if: ${{ !contains(github.event.head_commit.message, '[ci publish]') }} runs-on: ubuntu-22.04 permissions: contents: write diff --git a/lerna.json b/lerna.json index 2c9ae56..493dd39 100644 --- a/lerna.json +++ b/lerna.json @@ -5,7 +5,7 @@ "useNx": true, "command": { "version": { - "message": "chore(release): Publish 🚀 [ci publish]", + "message": "chore(release): [skip ci] Publish 🚀", "allowBranch": ["main", "development"], "conventional-commits": true, "create-release": "github" From ec23ff33d1bf96c2f0479d620840333b9aaee7b8 Mon Sep 17 00:00:00 2001 From: Spikatrix <12792882+Spikatrix@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:52:30 +0530 Subject: [PATCH 8/8] chore: use main as development branch and release as release branch --- .github/workflows/release.yml | 6 +++--- ...ync-dev-branch.yml => sync-main-branch.yml} | 18 +++++++++--------- lerna.json | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) rename .github/workflows/{sync-dev-branch.yml => sync-main-branch.yml} (61%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d374f5e..c078dc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - development + - release concurrency: ${{ github.workflow }}-${{ github.ref }} @@ -40,7 +40,7 @@ jobs: - name: Bump version and create release run: | - if [ "${{ github.ref_name }}" == "development" ]; then + if [ "${{ github.ref_name }}" == "main" ]; then yarn lerna version --yes --conventional-commits --conventional-prerelease --exact --create-release github --preid beta --loglevel silly else yarn lerna version --yes --conventional-commits --conventional-graduate --exact --create-release github --loglevel silly @@ -50,7 +50,7 @@ jobs: - name: Publish to NPM run: | - if [ "${{ github.ref_name }}" == "development" ]; then + if [ "${{ github.ref_name }}" == "main" ]; then yarn lerna publish from-package --yes --no-private --loglevel silly --preid beta --dist-tag beta else yarn lerna publish from-package --yes --no-private --loglevel silly diff --git a/.github/workflows/sync-dev-branch.yml b/.github/workflows/sync-main-branch.yml similarity index 61% rename from .github/workflows/sync-dev-branch.yml rename to .github/workflows/sync-main-branch.yml index 8fbb0ff..b7436b4 100644 --- a/.github/workflows/sync-dev-branch.yml +++ b/.github/workflows/sync-main-branch.yml @@ -1,4 +1,4 @@ -name: Sync development with main +name: Sync main with release on: push: @@ -6,7 +6,7 @@ on: - main jobs: - sync-development: + sync-main-branch: runs-on: ubuntu-22.04 permissions: contents: read @@ -15,21 +15,21 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Create pull request to development + - name: Create PR from release to main env: GH_TOKEN: ${{ github.token }} run: | - # Check if a pull request already exists from main to development - pr_url=$(gh pr list --head main --base development --json url --jq '.[0].url') + # Check if a pull request already exists from release to main + pr_url=$(gh pr list --head release --base main --json url --jq '.[0].url') if [ -n "$pr_url" ]; then echo "PR already exists: $pr_url" else pr_url=$(gh pr create \ - --base development \ - --head main \ - --title "[skip ci] Sync development with main" \ - --body "Auto-created pull request to merge changes from main into development." + --head release \ + --base main \ + --title "[skip ci][skip release] Sync main with the release branch" \ + --body "Auto-created pull request to merge changes from release into main." ) echo "Created PR: $pr_url" fi diff --git a/lerna.json b/lerna.json index 493dd39..d3e1e12 100644 --- a/lerna.json +++ b/lerna.json @@ -6,7 +6,7 @@ "command": { "version": { "message": "chore(release): [skip ci] Publish 🚀", - "allowBranch": ["main", "development"], + "allowBranch": ["main", "release"], "conventional-commits": true, "create-release": "github" }