From 3dff699ad536755e4048f0018b50a718d9fc31cc Mon Sep 17 00:00:00 2001 From: Artur Finger Date: Mon, 20 Nov 2023 13:03:26 +0200 Subject: [PATCH 1/2] Cleanup "Build" action --- .github/workflows/{ci-build.yml => build.yml} | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) rename .github/workflows/{ci-build.yml => build.yml} (72%) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/build.yml similarity index 72% rename from .github/workflows/ci-build.yml rename to .github/workflows/build.yml index 2fab8cd..c50c2ad 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: CI Build +name: Build on: push: @@ -7,21 +7,22 @@ on: pull_request: branches: - main - + jobs: build: name: Build runs-on: [ubuntu-latest] - + steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - name: Setup Node + - name: Setup Node + uses: actions/setup-node@v3 with: node-version: 16 cache: npm - + - name: NPM Install run: npm ci From b9824cba8d0fbaf9cbd33aab76685d0c66c979a4 Mon Sep 17 00:00:00 2001 From: Artur Finger Date: Mon, 20 Nov 2023 13:25:00 +0200 Subject: [PATCH 2/2] DE-6746: WIP publish NPM & docs --- .github/workflows/createdrel.yml | 13 ++++++ .github/workflows/publish.yml | 75 ++++++++++++++++++++++++++++++++ README_INTERNAL.md | 8 ++-- package.json | 3 +- scripts/prepublish.sh | 7 --- 5 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/createdrel.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 scripts/prepublish.sh diff --git a/.github/workflows/createdrel.yml b/.github/workflows/createdrel.yml new file mode 100644 index 0000000..a54b18a --- /dev/null +++ b/.github/workflows/createdrel.yml @@ -0,0 +1,13 @@ +name: Release created + +on: + release: + types: [created] + +jobs: + publish: + name: Release created Debug + runs-on: [ubuntu-latest] + steps: + - name: Checkout Code + run: echo "release created lol" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c665f61 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,75 @@ +name: Publish + +on: + release: + types: [released] + +# TODO switch out envs +env: + NPM_TOKEN: ${{ secrets.CLPLAYERS_NPM_TOKEN_RW }} + # VERSION: ${{ github.event.release.tag_name }} + # WEB_PATH: "react-dom/${{ env.VERSION }}/docs/" + VERSION: 0.7.7 + WEB_PATH: "react-dom/0.7.7/docs/" + +permissions: + contents: read # Permission for actions/checkout + id-token: write # Permission for aws-actions/configure-aws-credentials + +jobs: + publish: + name: Publish + runs-on: [ubuntu-latest] + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: npm + + - name: Install Dependencies + run: npm ci + + - name: Write NPM RC File + run: | + echo '@castlabs:registry=https://registry.npmjs.org' > .npmrc + echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc + + - name: Set Package Version + run: npm --no-git-tag-version --allow-same-version version ${{ env.VERSION }} + + - name: Build + run: npm run build + + # TODO remove the --dry-run + - name: Publish to NPM + run: npm publish --dry-run + + - name: Add NPM Release Job summary + run: | + echo '### NPM Release' >> $GITHUB_STEP_SUMMARY + echo "Released version ${{ env.VERSION }} of https://www.npmjs.com/package/@castlabs/prestoplay-react-components" >> $GITHUB_STEP_SUMMARY + + - name: Build Storybook + run: npm run build-storybook + + - name: Assume AWS role + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: arn:aws:iam::068037490145:role/prestoplay-web-web-uploader + aws-region: us-east-1 + + # TODO remove the --dryrun + - name: Upload to S3 + run: aws s3 cp --dryrun --recursive “./dist/storybook" "s3://players-castlabs-com-root/${{ env.WEB_PATH }}" + # Note: the default cache policy is 1 day, I think that's OK for now. + # In the future if traffic increases we can increase the expiration + # as much as we want. + + - name: Add Docs Publish Job Summary + run: | + echo '### Docs' >> $GITHUB_STEP_SUMMARY + echo "Published docs to https://players.castlabs.com/${{ env.WEB_PATH }}" >> $GITHUB_STEP_SUMMARY diff --git a/README_INTERNAL.md b/README_INTERNAL.md index 382a35d..4865e5c 100644 --- a/README_INTERNAL.md +++ b/README_INTERNAL.md @@ -24,10 +24,8 @@ npm run build ## Publish -To publish the library: -```sh -npm run publish -``` +TODO auto via pipeline. Just create a release > create a new tag > +this will trigger auto publish to NPM and docs. ## Test @@ -42,3 +40,5 @@ We are transitioning to use `Storybook` for public docs. Once that is done `app` ```sh npm run storybook ``` + +## Publishing diff --git a/package.json b/package.json index b265969..d5938af 100644 --- a/package.json +++ b/package.json @@ -16,14 +16,13 @@ "module": "dist/index.js", "types": "dist/prestoplay-react.d.ts", "scripts": { - "prepublishOnly": "bash ./scripts/prepublish.sh", "build": "bash ./scripts/build.sh", "start": "bash ./scripts/start.sh", "test": "jest", "test:watch": "jest --watch", "lint": "npx eslint .", "storybook": "storybook dev --port 6006", - "build-storybook": "storybook build --output-dir ./dist/storybook" + "build-storybook": "storybook build --debug --output-dir ./dist/storybook" }, "license": "Apache-2.0", "devDependencies": { diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh deleted file mode 100644 index 43c67c9..0000000 --- a/scripts/prepublish.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e; - -npm run test; -npm run build; -npx es-check es5 ./dist/prestoplay-react.cjs.min.js;