Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up current "Build" step #17

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/ci-build.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Build
name: Build

on:
push:
Expand All @@ -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

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/createdrel.yml
Original file line number Diff line number Diff line change
@@ -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"
75 changes: 75 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README_INTERNAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -42,3 +40,5 @@ We are transitioning to use `Storybook` for public docs. Once that is done `app`
```sh
npm run storybook
```

## Publishing
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 0 additions & 7 deletions scripts/prepublish.sh

This file was deleted.