From 380a1d87e3a4f80bd506356d6c190e8e72cbe667 Mon Sep 17 00:00:00 2001 From: Mike Chu <104384559+mikechu-optimizely@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:03:23 -0400 Subject: [PATCH] [FSSDK-9494] Tag release correctly during publishing (#220) * Add logic to handle proper taging * Remove testing bits --- .github/workflows/react_release.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react_release.yml b/.github/workflows/react_release.yml index a84c784..df50c3a 100644 --- a/.github/workflows/react_release.yml +++ b/.github/workflows/react_release.yml @@ -11,15 +11,34 @@ jobs: steps: - name: Checkout branch uses: actions/checkout@v4 + - name: Set up Node uses: actions/setup-node@v3 with: node-version: 18 registry-url: "https://registry.npmjs.org/" always-auth: "true" + env: + NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_REACT_TO_NPM_FROM_GITHUB }} + - name: Install dependencies run: yarn install + + - id: npm-tag + name: Determine NPM tag + run: | + version=$(jq -r '.version' package.json) + if [[ "$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=latest" >> "$GITHUB_OUTPUT" + fi + - name: Test, build, then publish env: NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_REACT_TO_NPM_FROM_GITHUB }} - run: npm publish + run: npm publish --tag ${{ steps.npm-tag.outputs['npm-tag'] }}