From 202772badb082cccebc5a2cc46328fd33155e2ee Mon Sep 17 00:00:00 2001 From: FarhanAnjum-opti Date: Mon, 10 Mar 2025 16:44:35 +0600 Subject: [PATCH 1/5] Renamed release to release_npm Added a new workflow release_gpr for release in GPR --- .github/workflows/release_gpr.yml | 74 +++++++++++++++++++ .../{release.yml => release_npm.yml} | 0 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/release_gpr.yml rename .github/workflows/{release.yml => release_npm.yml} (100%) diff --git a/.github/workflows/release_gpr.yml b/.github/workflows/release_gpr.yml new file mode 100644 index 000000000..85f017648 --- /dev/null +++ b/.github/workflows/release_gpr.yml @@ -0,0 +1,74 @@ +name: Publish SDK to GitHub Package Registry + +on: + release: + types: [published, edited] + workflow_dispatch: {} + +jobs: + publish: + name: Publish to GitHub Package Registry + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} + steps: + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: "https://npm.pkg.github.com/" + always-auth: "true" + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: npm install + + - id: latest-release + name: Export latest release git tag + run: | + echo "latest-release-tag=$(curl -qsSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ + | jq -r .tag_name)" >> $GITHUB_OUTPUT + + - id: npm-tag + name: Determine NPM tag + env: + GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + VERSION=$(jq -r '.version' package.json) + LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" + + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + RELEASE_TAG=${GITHUB_REF#refs/tags/} + else + RELEASE_TAG=$GITHUB_RELEASE_TAG + fi + + if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then + echo "npm-tag=latest" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-beta"* ]]; then + echo "npm-tag=beta" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-alpha"* ]]; then + echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-rc"* ]]; then + echo "npm-tag=rc" >> "$GITHUB_OUTPUT" + else + echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" + fi + + - id: release + name: Test, build, and publish to GitHub Package Registry + env: + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + DRY_RUN="--dry-run" + fi + npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --registry=https://npm.pkg.github.com/ $DRY_RUN diff --git a/.github/workflows/release.yml b/.github/workflows/release_npm.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/release_npm.yml From c17fe5071f18755ba1dd48ec0cc467448f3fb085 Mon Sep 17 00:00:00 2001 From: FarhanAnjum-opti Date: Mon, 10 Mar 2025 21:24:11 +0600 Subject: [PATCH 2/5] added gpr publish workflow to release.yml --- .github/workflows/release.yml | 141 ++++++++++++++++++++++++++++++ .github/workflows/release_gpr.yml | 74 ---------------- .github/workflows/release_npm.yml | 81 ----------------- 3 files changed, 141 insertions(+), 155 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/release_gpr.yml delete mode 100644 .github/workflows/release_npm.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..832bbe674 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,141 @@ +name: Publish SDK to NPM and GPR + +on: + release: + types: [published, edited] + workflow_dispatch: {} + +jobs: + publish_to_npm: + name: Publish to NPM + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} + steps: + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: "https://registry.npmjs.org/" + always-auth: "true" + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + - name: Install dependencies + run: npm install + + - id: latest-release + name: Export latest release git tag + run: | + echo "latest-release-tag=$(curl -qsSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ + | jq -r .tag_name)" >> $GITHUB_OUTPUT + + - id: npm-tag + name: Determine NPM tag + env: + GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + VERSION=$(jq -r '.version' package.json) + LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" + + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + RELEASE_TAG=${GITHUB_REF#refs/tags/} + else + RELEASE_TAG=$GITHUB_RELEASE_TAG + fi + + if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then + echo "npm-tag=latest" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-beta"* ]]; then + echo "npm-tag=beta" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-alpha"* ]]; then + echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-rc"* ]]; then + echo "npm-tag=rc" >> "$GITHUB_OUTPUT" + else + echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" + fi + + - id: release + name: Test, build and publish to npm + env: + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + run: | + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + DRY_RUN="--dry-run" + fi + npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN + + publish_to_gpr: + name: Publish to GitHub Package Registry + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} + steps: + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Setup Node.js for GPR + uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: 'https://npm.pkg.github.com/' + always-auth: true + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: npm install + + - id: latest-release + name: Export latest release git tag + run: | + echo "latest-release-tag=$(curl -qsSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ + | jq -r .tag_name)" >> $GITHUB_OUTPUT + + - id: npm-tag + name: Determine NPM tag + env: + GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + VERSION=$(jq -r '.version' package.json) + LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" + + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + RELEASE_TAG=${GITHUB_REF#refs/tags/} + else + RELEASE_TAG=$GITHUB_RELEASE_TAG + fi + + if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then + echo "npm-tag=latest" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-beta"* ]]; then + echo "npm-tag=beta" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-alpha"* ]]; then + echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-rc"* ]]; then + echo "npm-tag=rc" >> "$GITHUB_OUTPUT" + else + echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" + fi + + - id: release + name: Test, build and publish to gpr + env: + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + DRY_RUN="--dry-run" + fi + npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --registry=https://npm.pkg.github.com/ $DRY_RUN diff --git a/.github/workflows/release_gpr.yml b/.github/workflows/release_gpr.yml deleted file mode 100644 index 85f017648..000000000 --- a/.github/workflows/release_gpr.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Publish SDK to GitHub Package Registry - -on: - release: - types: [published, edited] - workflow_dispatch: {} - -jobs: - publish: - name: Publish to GitHub Package Registry - runs-on: ubuntu-latest - if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} - steps: - - name: Checkout branch - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: "https://npm.pkg.github.com/" - always-auth: "true" - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install dependencies - run: npm install - - - id: latest-release - name: Export latest release git tag - run: | - echo "latest-release-tag=$(curl -qsSL \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ - | jq -r .tag_name)" >> $GITHUB_OUTPUT - - - id: npm-tag - name: Determine NPM tag - env: - GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} - run: | - VERSION=$(jq -r '.version' package.json) - LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" - - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - RELEASE_TAG=${GITHUB_REF#refs/tags/} - else - RELEASE_TAG=$GITHUB_RELEASE_TAG - fi - - if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then - echo "npm-tag=latest" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-beta"* ]]; then - echo "npm-tag=beta" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-alpha"* ]]; then - echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-rc"* ]]; then - echo "npm-tag=rc" >> "$GITHUB_OUTPUT" - else - echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" - fi - - - id: release - name: Test, build, and publish to GitHub Package Registry - env: - BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} - BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - DRY_RUN="--dry-run" - fi - npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --registry=https://npm.pkg.github.com/ $DRY_RUN diff --git a/.github/workflows/release_npm.yml b/.github/workflows/release_npm.yml deleted file mode 100644 index ba839b17d..000000000 --- a/.github/workflows/release_npm.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Publish SDK to NPM - -on: - release: - types: [published, edited] - workflow_dispatch: {} - -jobs: - publish: - name: Publish to NPM - runs-on: ubuntu-latest - if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} - steps: - - name: Checkout branch - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: "https://registry.npmjs.org/" - always-auth: "true" - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - - - name: Install dependencies - run: npm install - - - id: latest-release - name: Export latest release git tag - run: | - echo "latest-release-tag=$(curl -qsSL \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ - | jq -r .tag_name)" >> $GITHUB_OUTPUT - - - id: npm-tag - name: Determine NPM tag - env: - GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} - run: | - VERSION=$(jq -r '.version' package.json) - LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" - - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - RELEASE_TAG=${GITHUB_REF#refs/tags/} - else - RELEASE_TAG=$GITHUB_RELEASE_TAG - fi - - if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then - echo "npm-tag=latest" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-beta"* ]]; then - echo "npm-tag=beta" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-alpha"* ]]; then - echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-rc"* ]]; then - echo "npm-tag=rc" >> "$GITHUB_OUTPUT" - else - echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" - fi - - - id: release - name: Test, build and publish to npm - env: - BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} - BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - run: | - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - DRY_RUN="--dry-run" - fi - npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN - - # - name: Report results to Jellyfish - # uses: optimizely/jellyfish-deployment-reporter-action@main - # if: ${{ always() && github.event_name == 'release' && (steps.release.outcome == 'success' || steps.release.outcome == 'failure') }} - # with: - # jellyfish_api_token: ${{ secrets.JELLYFISH_API_TOKEN }} - # is_successful: ${{ steps.release.outcome == 'success' }} From e694f39cf91fc7bc3bdc3181e9eb3e933d6cf032 Mon Sep 17 00:00:00 2001 From: FarhanAnjum-opti Date: Mon, 17 Mar 2025 17:37:56 +0600 Subject: [PATCH 3/5] Refactored to use common-publish.yml for NPM and GPR. Removed repetitive steps like setup and checkout. Added common parameters for secret tokens and registry URLs. --- .github/workflows/common-publish.yml | 83 ++++++++++++++++ .github/workflows/release.yml | 140 +++------------------------ 2 files changed, 95 insertions(+), 128 deletions(-) create mode 100644 .github/workflows/common-publish.yml diff --git a/.github/workflows/common-publish.yml b/.github/workflows/common-publish.yml new file mode 100644 index 000000000..46f34e657 --- /dev/null +++ b/.github/workflows/common-publish.yml @@ -0,0 +1,83 @@ +name: Common Publish Steps + +on: + workflow_call: + inputs: + registry-url: + required: true + type: string + node-auth-token: + required: true + type: string + browserstack-username: + required: true + type: string + browserstack-access-key: + required: true + type: string + +jobs: + common-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: ${{ inputs.registry-url }} + always-auth: true + env: + NODE_AUTH_TOKEN: ${{ inputs.node-auth-token }} + + - name: Install dependencies + run: npm install + + - id: latest-release + name: Export latest release git tag + run: | + echo "latest-release-tag=$(curl -qsSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ inputs.node-auth-token }}" \ + "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ + | jq -r .tag_name)" >> $GITHUB_OUTPUT + + - id: npm-tag + name: Determine NPM tag + env: + GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + VERSION=$(jq -r '.version' package.json) + LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" + + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + RELEASE_TAG=${GITHUB_REF#refs/tags/} + else + RELEASE_TAG=$GITHUB_RELEASE_TAG + fi + + if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then + echo "npm-tag=latest" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-beta"* ]]; then + echo "npm-tag=beta" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-alpha"* ]]; then + echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" + elif [[ "$VERSION" == *"-rc"* ]]; then + echo "npm-tag=rc" >> "$GITHUB_OUTPUT" + else + echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" + fi + + - id: release + name: Test, build and publish + env: + BROWSERSTACK_USERNAME: ${{ inputs.browserstack-username }} + BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack-access-key }} + NODE_AUTH_TOKEN: ${{ inputs.node-auth-token }} + run: | + if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then + DRY_RUN="--dry-run" + fi + npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --registry=${{ inputs.registry-url }} $DRY_RUN \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 832bbe674..8e4526baf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,134 +8,18 @@ on: jobs: publish_to_npm: name: Publish to NPM - runs-on: ubuntu-latest - if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} - steps: - - name: Checkout branch - uses: actions/checkout@v4 + uses: ./.github/workflows/common-publish.yml + with: + registry-url: 'https://registry.npmjs.org/' + node-auth-token: ${{ secrets.NPM_PUBLISH_TOKEN }} + browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }} + browserstack-access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: "https://registry.npmjs.org/" - always-auth: "true" - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - - - name: Install dependencies - run: npm install - - - id: latest-release - name: Export latest release git tag - run: | - echo "latest-release-tag=$(curl -qsSL \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ - | jq -r .tag_name)" >> $GITHUB_OUTPUT - - - id: npm-tag - name: Determine NPM tag - env: - GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} - run: | - VERSION=$(jq -r '.version' package.json) - LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" - - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - RELEASE_TAG=${GITHUB_REF#refs/tags/} - else - RELEASE_TAG=$GITHUB_RELEASE_TAG - fi - - if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then - echo "npm-tag=latest" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-beta"* ]]; then - echo "npm-tag=beta" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-alpha"* ]]; then - echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-rc"* ]]; then - echo "npm-tag=rc" >> "$GITHUB_OUTPUT" - else - echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" - fi - - - id: release - name: Test, build and publish to npm - env: - BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} - BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - run: | - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - DRY_RUN="--dry-run" - fi - npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN - publish_to_gpr: name: Publish to GitHub Package Registry - runs-on: ubuntu-latest - if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }} - steps: - - name: Checkout branch - uses: actions/checkout@v4 - - - name: Setup Node.js for GPR - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: 'https://npm.pkg.github.com/' - always-auth: true - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install dependencies - run: npm install - - - id: latest-release - name: Export latest release git tag - run: | - echo "latest-release-tag=$(curl -qsSL \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ - | jq -r .tag_name)" >> $GITHUB_OUTPUT - - - id: npm-tag - name: Determine NPM tag - env: - GITHUB_RELEASE_TAG: ${{ github.event.release.tag_name }} - run: | - VERSION=$(jq -r '.version' package.json) - LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}" - - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - RELEASE_TAG=${GITHUB_REF#refs/tags/} - else - RELEASE_TAG=$GITHUB_RELEASE_TAG - fi - - if [[ $RELEASE_TAG == $LATEST_RELEASE_TAG ]]; then - echo "npm-tag=latest" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-beta"* ]]; then - echo "npm-tag=beta" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-alpha"* ]]; then - echo "npm-tag=alpha" >> "$GITHUB_OUTPUT" - elif [[ "$VERSION" == *"-rc"* ]]; then - echo "npm-tag=rc" >> "$GITHUB_OUTPUT" - else - echo "npm-tag=v$(echo $VERSION | awk -F. '{print $1}')-latest" >> "$GITHUB_OUTPUT" - fi - - - id: release - name: Test, build and publish to gpr - env: - BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} - BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then - DRY_RUN="--dry-run" - fi - npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --registry=https://npm.pkg.github.com/ $DRY_RUN + uses: ./.github/workflows/common-publish.yml + with: + registry-url: 'https://npm.pkg.github.com/' + node-auth-token: ${{ secrets.GITHUB_TOKEN }} + browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }} + browserstack-access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} \ No newline at end of file From 2e26b4997e8a84829d2df1cb0ffbc794abf54e2f Mon Sep 17 00:00:00 2001 From: FarhanAnjum-opti Date: Mon, 17 Mar 2025 17:42:03 +0600 Subject: [PATCH 4/5] .github/workflows/release.yml -> Removed 'edited' type from triggers. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e4526baf..f761f19c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Publish SDK to NPM and GPR on: release: - types: [published, edited] + types: [published] workflow_dispatch: {} jobs: From 328d9afd4e577ba67077a5fff911709756623350 Mon Sep 17 00:00:00 2001 From: FarhanAnjum-opti Date: Mon, 17 Mar 2025 20:08:12 +0600 Subject: [PATCH 5/5] .github/workflows/common-publish.yml -> Update token key for auth --- .github/workflows/common-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/common-publish.yml b/.github/workflows/common-publish.yml index 46f34e657..e2fa7e752 100644 --- a/.github/workflows/common-publish.yml +++ b/.github/workflows/common-publish.yml @@ -40,7 +40,7 @@ jobs: run: | echo "latest-release-tag=$(curl -qsSL \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ inputs.node-auth-token }}" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" \ | jq -r .tag_name)" >> $GITHUB_OUTPUT