From 639864b19ecf2cbbad6df3556b2ca0a2cdb38251 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 06:38:30 +0100 Subject: [PATCH 01/10] ci(release): Add initial post-release workflow --- .github/workflows/post-release.yml | 30 ++++++++++++++++++++++++++++++ nx.json | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/post-release.yml diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml new file mode 100644 index 0000000..85f5bc7 --- /dev/null +++ b/.github/workflows/post-release.yml @@ -0,0 +1,30 @@ +name: Extract Project from Tag + +on: + push: + tags: + - "*@*.*.*" + workflow_dispatch: + +jobs: + extract-project: + runs-on: ubuntu-latest + steps: + - name: Extract Project Name + id: extract + run: | + TAG_NAME=${{ github.ref_name }} + PROJECT_NAME=$(echo "$TAG_NAME" | sed -E 's/@[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?//') + echo "project=$PROJECT_NAME" >> "$GITHUB_ENV" + echo "::set-output name=project::$PROJECT_NAME" + + - name: Show Extracted Project + run: | + echo "Extracted project: ${{ env.project }}" + + use-project: + runs-on: ubuntu-latest + needs: extract-project + steps: + - name: Use Extracted Project Name + run: echo "Project from tag is ${{ needs.extract-project.outputs.project }}" diff --git a/nx.json b/nx.json index 1edd921..d86d008 100644 --- a/nx.json +++ b/nx.json @@ -97,7 +97,7 @@ "generatorOptions": { "fallbackCurrentVersionResolver": "disk" }, - "preVersionCommand": "yarn nx run-many -t build", + "preVersionCommand": "yarn nx run-many -t build" }, "changelog": { "projectChangelogs": true, From dae62178faf9a5a1e6faeb0aacd8ef4602d04f51 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 06:43:46 +0100 Subject: [PATCH 02/10] ci(release): Test trigger new workflow --- .github/workflows/post-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 85f5bc7..fcbb93d 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -1,7 +1,9 @@ -name: Extract Project from Tag +name: Post Release on: push: + branches: + - feat/add-post-release-workflow tags: - "*@*.*.*" workflow_dispatch: From a33a25e25c2cc3d7eae30cb9b2dfd8828e6e7c42 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 07:07:20 +0100 Subject: [PATCH 03/10] ci(release): Upload tests coverage report to Codecov --- .github/workflows/post-release.yml | 54 +++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index fcbb93d..5ad9821 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -6,27 +6,57 @@ on: - feat/add-post-release-workflow tags: - "*@*.*.*" - workflow_dispatch: jobs: extract-project: runs-on: ubuntu-latest steps: - name: Extract Project Name - id: extract + id: extract-project-name + shell: bash run: | TAG_NAME=${{ github.ref_name }} - PROJECT_NAME=$(echo "$TAG_NAME" | sed -E 's/@[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?//') - echo "project=$PROJECT_NAME" >> "$GITHUB_ENV" - echo "::set-output name=project::$PROJECT_NAME" + if [[ "$TAG_NAME" =~ ^(.+)@[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then + PROJECT_NAME=${BASH_REMATCH[1]} + else + PROJECT_NAME="" + fi + echo "project=$PROJECT_NAME" >> "$GITHUB_OUTPUT" + echo "Extracted project '$PROJECT_NAME' from '$TAG_NAME'" - - name: Show Extracted Project - run: | - echo "Extracted project: ${{ env.project }}" - - use-project: + upload-test-coverage: runs-on: ubuntu-latest needs: extract-project + if: ${{ needs.extract-project.outputs.project != '' }} + env: + PROJECT: ${{ needs.extract-project.outputs.project }} steps: - - name: Use Extracted Project Name - run: echo "Project from tag is ${{ needs.extract-project.outputs.project }}" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-tags: 'true' + fetch-depth: '0' + + - name: Enable Corepack + run: corepack enable + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org/' + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + + - name: Install dependencies + run: yarn install --immutable + + - name: Run tests with coverage + run: npx nx run ${{ env.PROJECT }}:test --coverage + + - name: Upload ${{ env.PROJECT }} coverage reports to Codecov + uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + directory: ./coverage/packages/${{ env.PROJECT }} + flags: hooks,${{ env.PROJECT }} From c4f83934127a9b1d3a59d465b69f54e1384a13fe Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 07:15:44 +0100 Subject: [PATCH 04/10] ci(release): Fix using project as an output from previous job --- .github/workflows/post-release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 5ad9821..92d10ab 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -9,7 +9,10 @@ on: jobs: extract-project: + name: Extract project name from git tag runs-on: ubuntu-latest + outputs: + project: ${{ steps.extract-project-name.outputs.project }} steps: - name: Extract Project Name id: extract-project-name @@ -25,6 +28,7 @@ jobs: echo "Extracted project '$PROJECT_NAME' from '$TAG_NAME'" upload-test-coverage: + name: Upload tests coverage for project runs-on: ubuntu-latest needs: extract-project if: ${{ needs.extract-project.outputs.project != '' }} From 8eb0f187f4a5c5a63dd69067604ef9d360c311b4 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 07:17:42 +0100 Subject: [PATCH 05/10] ci(release): Remove test run branch push --- .github/workflows/post-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 92d10ab..06353a7 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -2,8 +2,6 @@ name: Post Release on: push: - branches: - - feat/add-post-release-workflow tags: - "*@*.*.*" From 3a6e772adf8ca4566a69e776bdd33ecdcdb23fb3 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 07:22:42 +0100 Subject: [PATCH 06/10] ci(release): Remove hooks flag from Codecov upload --- .github/workflows/post-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 06353a7..56dcc66 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -61,4 +61,4 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} directory: ./coverage/packages/${{ env.PROJECT }} - flags: hooks,${{ env.PROJECT }} + flags: ${{ env.PROJECT }} From a83dd3d0ef161b454a8e82bd5ba5fdc080df6f95 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 07:40:32 +0100 Subject: [PATCH 07/10] ci(pr): Rename verify PR job --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 41ed3e5..d29ba1d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -12,7 +12,7 @@ on: branches: ['main'] jobs: - build: + verify-pr: runs-on: ubuntu-latest strategy: From be2b1ee5e46f5504f7ae2cb751ebb5cf17118b77 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 07:52:39 +0100 Subject: [PATCH 08/10] ci(pr): Add report status job for properly setting PR status checks --- .github/workflows/verify.yml | 38 ++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index d29ba1d..d824fe0 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -62,24 +62,20 @@ jobs: json-summary-path: ../../coverage/packages/${{ matrix.package }}/coverage-summary.json json-final-path: ../../coverage/packages/${{ matrix.package }}/coverage-final.json - -# - name: Upload use-long-press coverage reports to Codecov -# uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 -# with: -# token: ${{ secrets.CODECOV_TOKEN }} -# directory: ./coverage/packages/use-long-press -# flags: hooks,use-long-press -# -# - name: Upload use-double-tap coverage reports to Codecov -# uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 -# with: -# token: ${{ secrets.CODECOV_TOKEN }} -# directory: ./coverage/packages/use-double-tap -# flags: hooks,use-double-tap -# -# - name: Upload react-interval-hook coverage reports to Codecov -# uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 -# with: -# token: ${{ secrets.CODECOV_TOKEN }} -# directory: ./coverage/packages/react-interval-hook -# flags: hooks,react-interval-hook + report-status: + name: Report PR verification status + runs-on: ubuntu-latest + needs: verify-pr + if: always() # Ensures it runs even if a matrix job fails + steps: + - name: Determine overall status + run: | + if [[ "${{ needs.verify-pr.result }}" == "success" ]]; then + echo "All matrix jobs passed ✅" + exit 0 + else + echo "Some matrix jobs failed ❌" + exit 1 + fi + outputs: + status: ${{ job.status }} From ab7279726d0149b2907c5aaeb43303cfc87aa3c4 Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 08:04:46 +0100 Subject: [PATCH 09/10] ci(release): Add permissions to post-release workflow --- .github/workflows/post-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 56dcc66..ae0e1d8 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -1,5 +1,8 @@ name: Post Release +permissions: + contents: read + on: push: tags: From 72c41f6d6b50df9297a9ed0c2008fb5c29a9f54c Mon Sep 17 00:00:00 2001 From: minwork <20630104+minwork@users.noreply.github.com> Date: Tue, 18 Mar 2025 08:13:00 +0100 Subject: [PATCH 10/10] ci(release): Add CODEOWNERS file --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..5b021ae --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Code owners for all files +* @minwork