Skip to content

Publish Package

Publish Package #31

Workflow file for this run

name: Publish Package
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: write
id-token: write
pages: write
deployments: write
jobs:
# Re-run checks to be 100% sure (release could be created manually)
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run all checks
run: |
pnpm check:lint
pnpm check:types
pnpm check:test
pnpm build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 1
publish-storybook:
needs: verify
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build Storybook
env:
NODE_OPTIONS: "--max_old_space_size=16384"
run: pnpm run build-storybook
- name: Create CNAME record file
run: echo "yail.programmer-network" > ./storybook-static/CNAME
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./storybook-static"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
publish-npm:
needs: verify
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
scope: "@programmer_network"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish summary
run: |
echo "# 🎉 Package Published Successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Package:** @programmer_network/yail" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ github.event.release.tag_name }}" >> $GITHUB_STEP_SUMMARY
echo "**NPM:** https://www.npmjs.com/package/@programmer_network/yail" >> $GITHUB_STEP_SUMMARY
echo "**Storybook:** https://yail.programmer-network" >> $GITHUB_STEP_SUMMARY