Publish #35
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
release: | |
types: [released] | |
env: | |
NPM_TOKEN: ${{ secrets.CLPLAYERS_NPM_TOKEN_RW }} | |
VERSION: ${{ github.event.release.tag_name }} | |
WEB_PATH: "react-dom/${{ github.event.release.tag_name }}/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: Apply version to package.json, readme and docs | |
uses: ./.github/actions/apply-version | |
with: | |
version: ${{ env.VERSION }} | |
## Publish the API docs | |
- name: Build Storybook | |
run: npm run build-storybook | |
- name: Assume AWS role | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ secrets.AWS_UPLOADER_ROLE_PLAYERS }} | |
aws-region: us-east-1 | |
- name: Upload to S3 | |
run: aws s3 cp --recursive "./dist/storybook" "${{ secrets.AWS_WEB_BUCKET }}/${{ 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. | |
## Publish the NPM package | |
- name: Write NPM RC File | |
run: | | |
echo '@castlabs:registry=https://registry.npmjs.org' > .npmrc | |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc | |
- name: Build | |
run: npm run build | |
- name: Publish to NPM | |
uses: ./.github/actions/publish | |
with: | |
version: ${{ env.VERSION }} | |
dryRun: false | |
- name: Add 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 | |
echo '### Docs' >> $GITHUB_STEP_SUMMARY | |
echo "Published docs to https://players.castlabs.com/${{ env.WEB_PATH }}" >> $GITHUB_STEP_SUMMARY |