From c83971f12e8ad8798211c8be3bb25dae8bc9ebb9 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:14:39 -0800 Subject: [PATCH 01/11] get tag_branch_name in the workflow file --- .github/scripts/tag_ref.sh | 6 ------ .github/workflows/publish.yml | 11 ++++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 .github/scripts/tag_ref.sh diff --git a/.github/scripts/tag_ref.sh b/.github/scripts/tag_ref.sh deleted file mode 100644 index fbf1c1f..0000000 --- a/.github/scripts/tag_ref.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -raw=$(git branch -r --contains $1) -branch=${raw##*/} || "" - -echo "TAG_BRANCH=$branch" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 56f2226..8a5513b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,13 +21,18 @@ jobs: prepare: runs-on: ubuntu-latest outputs: - TAG_BRANCH: ${{ env.TAG_BRANCH }} + TAG_BRANCH: ${{ env.TAG_BRANCH_NAME }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: get-tag-branch - run: bash .github/scripts/tag_ref.sh ${{ github.ref }} + + - id: prepare_env + run: | + RAW=$(git branch -r --contains {{ github.ref }}) + TAG_BRANCH_NAME="${RAW##*/}" + echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV + - run: echo "${{ toJSON(env) }}" test: From fc098480aa0066ee04d1697059b98600b6d3e4bd Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:15:54 -0800 Subject: [PATCH 02/11] wrap github.ref in a quote --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8a5513b..3951366 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,7 +29,7 @@ jobs: - id: prepare_env run: | - RAW=$(git branch -r --contains {{ github.ref }}) + RAW=$(git branch -r --contains "${{ github.ref }}") TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From f5a33b663fbc1b4f92d5839f9ec42d74ce835194 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:17:19 -0800 Subject: [PATCH 03/11] remove the quote --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3951366..1b0bfe2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,7 +29,7 @@ jobs: - id: prepare_env run: | - RAW=$(git branch -r --contains "${{ github.ref }}") + RAW=$(git branch -r --contains ${{ github.ref }}) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From 039b0c3ae1475a7c490445984964ddcf8fad2f2c Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:20:45 -0800 Subject: [PATCH 04/11] construct the ref outside raw --- .github/workflows/publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1b0bfe2..24c7be1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,7 +29,9 @@ jobs: - id: prepare_env run: | - RAW=$(git branch -r --contains ${{ github.ref }}) + echo "GITHUB_REF=${{ github.ref }}" + + RAW=$(git branch -r --contains $GITHUB_REF) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From 0e81a27b8cfad2aa9f45c4cdd2a93c4ebc9ee130 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:23:16 -0800 Subject: [PATCH 05/11] debug-1 --- .github/workflows/publish.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 24c7be1..497db33 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,9 +29,13 @@ jobs: - id: prepare_env run: | - echo "GITHUB_REF=${{ github.ref }}" + echo "TAGGED=${{ startsWith(github.ref, 'refs/tags/v') }}" >> $GITHUB_OUTPUT + + SHORT_SHA=$(git rev-parse --short HEAD) + # echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT + # echo "GITHUB_REF=${{ github.ref }}" - RAW=$(git branch -r --contains $GITHUB_REF) + RAW=$(git branch -r --contains $SHORT_SHA) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From 9eef48704dfcde9380f6ccd06b0201bdaf0cd28c Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:24:55 -0800 Subject: [PATCH 06/11] debug-2 --- .github/workflows/publish.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 497db33..666f8a3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,13 +29,14 @@ jobs: - id: prepare_env run: | - echo "TAGGED=${{ startsWith(github.ref, 'refs/tags/v') }}" >> $GITHUB_OUTPUT + echo "TAGGED=${{ startsWith(github.ref, 'refs/tags/v') }}" >> $GITHUB_ENV SHORT_SHA=$(git rev-parse --short HEAD) - # echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT - # echo "GITHUB_REF=${{ github.ref }}" + echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV + + GITHUB_REF=${{ github.ref }} - RAW=$(git branch -r --contains $SHORT_SHA) + RAW=$(git branch -r --contains $GITHUB_REF) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From 50744feb83ac2d913d946365afcff5812c09e6c0 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:27:20 -0800 Subject: [PATCH 07/11] don't override the global github_ref object --- .github/workflows/publish.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 666f8a3..8d6f9d8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,8 +33,6 @@ jobs: SHORT_SHA=$(git rev-parse --short HEAD) echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV - - GITHUB_REF=${{ github.ref }} RAW=$(git branch -r --contains $GITHUB_REF) TAG_BRANCH_NAME="${RAW##*/}" From d10a269d4c4de7cb91b05995d5e7ec82405915e8 Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:31:44 -0800 Subject: [PATCH 08/11] use github_ref_name global env --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8d6f9d8..6fb7691 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,7 +34,7 @@ jobs: SHORT_SHA=$(git rev-parse --short HEAD) echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV - RAW=$(git branch -r --contains $GITHUB_REF) + RAW=$(git branch -r --contains $GITHUB_REF_NAME) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From 5e68501076c9e74a45428404a4a8fa291284210c Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:36:11 -0800 Subject: [PATCH 09/11] cleanup --- .github/workflows/publish.yml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6fb7691..18a31f8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,6 +22,8 @@ jobs: runs-on: ubuntu-latest outputs: TAG_BRANCH: ${{ env.TAG_BRANCH_NAME }} + SHORT_SHA: ${{ env.SHORT_SHA }} + TAGGED: ${{ env.TAGGED }} steps: - uses: actions/checkout@v3 with: @@ -34,7 +36,11 @@ jobs: SHORT_SHA=$(git rev-parse --short HEAD) echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV - RAW=$(git branch -r --contains $GITHUB_REF_NAME) + echo "$SHORT_SHA" + echo "$GITHUB_REF" + echo "$GITHUB_REF_NAME" + + RAW=$(git branch -r --contains $SHORT_SHA) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV @@ -66,28 +72,23 @@ jobs: **/node_modules key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: install dependencies - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: install - - name: build package - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: build - - name: build types - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: tsc - - name: test types - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: tsd - - name: test functionality - uses: borales/actions-yarn@v4 + - uses: borales/actions-yarn@v4 with: cmd: test @@ -105,11 +106,13 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: "16.x" + node-version: "18.x" + - uses: actions/download-artifact@v3 with: name: lib path: lib + - uses: heinrichreimer/github-changelog-generator-action@v2.3 with: token: ${{ secrets.GITHUB_TOKEN }} From 5b027c009bb7af5e9a300916f1d95d99add1b7ff Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:43:40 -0800 Subject: [PATCH 10/11] cleanup --- .github/workflows/publish.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 18a31f8..9302cbd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,10 +36,6 @@ jobs: SHORT_SHA=$(git rev-parse --short HEAD) echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV - echo "$SHORT_SHA" - echo "$GITHUB_REF" - echo "$GITHUB_REF_NAME" - RAW=$(git branch -r --contains $SHORT_SHA) TAG_BRANCH_NAME="${RAW##*/}" echo "TAG_BRANCH_NAME=$TAG_BRANCH_NAME" >> $GITHUB_ENV From b57e608af6875669708fa75b15c72626731bac9e Mon Sep 17 00:00:00 2001 From: Chukwuma Nwaugha Date: Thu, 16 Nov 2023 05:46:19 -0800 Subject: [PATCH 11/11] further cleanup --- .github/workflows/publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9302cbd..7b037b1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,6 @@ jobs: runs-on: ubuntu-latest outputs: TAG_BRANCH: ${{ env.TAG_BRANCH_NAME }} - SHORT_SHA: ${{ env.SHORT_SHA }} TAGGED: ${{ env.TAGGED }} steps: - uses: actions/checkout@v3 @@ -34,7 +33,6 @@ jobs: echo "TAGGED=${{ startsWith(github.ref, 'refs/tags/v') }}" >> $GITHUB_ENV SHORT_SHA=$(git rev-parse --short HEAD) - echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV RAW=$(git branch -r --contains $SHORT_SHA) TAG_BRANCH_NAME="${RAW##*/}" @@ -97,7 +95,7 @@ jobs: name: Publish to npmjs runs-on: ubuntu-latest needs: [prepare, test] - if: ${{ needs.prepare.outputs.TAG_BRANCH == 'main' && startsWith(github.ref, 'refs/tags/v') }} + if: ${{ needs.prepare.outputs.TAG_BRANCH == 'main' && needs.prepare.outputs.TAGGED == 'true' }} steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3