Skip to content

Commit

Permalink
ci(github): add continuous integration and deployment workflows
Browse files Browse the repository at this point in the history
Introduced new GitHub Actions workflows for continuous integration and deployment. The `CI` workflow is triggered on push to the main branch and pull requests, focusing on build, lint, and test sequences. The `Publish` workflow handles deployment to both private and public npm registries upon tagging and includes steps to create GitHub releases. These workflows are designed to improve the automation and reliability of code integration and deployment processes.
  • Loading branch information
shorwood committed Jul 28, 2024
1 parent e2d3c70 commit 697a12b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI
permissions:
id-token: write
contents: write

on:
push:
branches:
- main
paths:
- "packages/**"
pull_request:
branches:
- main

jobs:
ci:
name: Continuous Integration & Deployment to Private Registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 9.x
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
registry-url: "https://registry.npmjs.org/"

# --- Install, build, and test.
- run: pnpm install
- run: pnpm build
- run: pnpm lint:ci
- run: pnpm test:ci

# --- Publish to private registry on main branch.
# - if: github.event_name == 'push'
# run: pnpm publish:ci --registry https://npm.hsjm.dev --tag next
# env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN_PRIVATE}}
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish
permissions:
id-token: write
contents: write

on:
push:
tags:
- v*

jobs:
deploy:
name: Deployment to Private Registry & NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 9.x
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
registry-url: "https://registry.npmjs.org/"

# --- Install, build, and test.
- run: pnpm install
- run: pnpm build
- run: pnpm lint:ci
- run: pnpm test:ci

# --- Publish to private registry on main branch.
# - run: pnpm publish:ci --registry https://npm.hsjm.dev --tag latest
# env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN_PRIVATE}}

# --- Publish to NPM registry on main branch. (Only on tags)
- run: pnpm publish:ci --registry https://registry.npmjs.org --tag latest
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_CONFIG_PROVENANCE: true

# --- If all goes well, create a release on GitHub.
- run: npx changelogithub --no-group
continue-on-error: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 697a12b

Please sign in to comment.