mirror of
https://github.com/morten-olsen/bob.git
synced 2026-02-08 01:46:29 +01:00
115 lines
2.9 KiB
YAML
115 lines
2.9 KiB
YAML
name: Node.js Package
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
types: [opened]
|
|
# release:
|
|
# types: [created]
|
|
|
|
env:
|
|
NODE_CACHE: 'pnpm'
|
|
NODE_VERSION: '20.x'
|
|
NODE_SCOPE: '@bob-the-algorithm'
|
|
NPM_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: read
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- run: corepack enable
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
cache: '${{ env.NODE_CACHE }}'
|
|
node-version: '${{ env.NODE_VERSION }}'
|
|
registry-url: '${{ env.NODE_REGISTRY_URL }}'
|
|
scope: '${{ env.NODE_SCOPE }}'
|
|
|
|
- run: |
|
|
pnpm install
|
|
pnpm run build
|
|
- uses: actions/upload-artifact@v3
|
|
env:
|
|
ASSET_URL: https://mortenolsen.pro/bob
|
|
with:
|
|
name: lib
|
|
retention-days: 5
|
|
path: |
|
|
packages/*/dist
|
|
packages/*/package.json
|
|
package.json
|
|
README.md
|
|
update-release-draft:
|
|
if: github.ref == 'refs/heads/main'
|
|
needs: build
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
packages: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: release-drafter/release-drafter@v5
|
|
with:
|
|
config-name: release-drafter-config.yml
|
|
publish: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
release-web:
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
needs: [build, update-release-draft]
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: lib
|
|
path: ./
|
|
- name: Deploy to GitHub Pages
|
|
working-directory: ./packages/playground/dist
|
|
id: deployment
|
|
uses: actions/deploy-pages@v2
|
|
|
|
release-npm:
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
needs: [build, update-release-draft]
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- run: corepack enable
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
cache: '${{ env.NODE_CACHE }}'
|
|
node-version: '${{ env.NODE_VERSION }}'
|
|
scope: '${{ env.NODE_SCOPE }}'
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: lib
|
|
path: ./
|
|
- run: |
|
|
pnpm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
|
|
pnpm install
|
|
git config user.name "Github Actions Bot"
|
|
git config user.email "<>"
|
|
pnpm version $(git describe --tag --abbrev=0)
|
|
pnpm publish -r --publish-branch main --access public
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|