Skip to content

Commit

Permalink
Add build and publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mseaton committed Mar 15, 2024
1 parent 393a6b3 commit 8113b71
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 1 deletion.
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Build and Deploy

on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read

steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Run lint, type checks and tests
run: yarn verify

- name: Run build
run: yarn turbo run build --color

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: |
packages/**/dist
overwrite: true

pre_release:
runs-on: ubuntu-latest

needs: build

if: ${{ github.event_name == 'push' }}

steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Version
run: yarn workspaces foreach --worktree --topological --exclude @pih/openmrs-esm-pihemr version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}"

- name: Build
run: yarn turbo run build --color --concurrency=5

- run: git config user.email "[email protected]" && git config user.name "pihinformatics"
- run: git add . && git commit -m "Prerelease version" --no-verify

- name: Pre-release
run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:prepublish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: |
packages/**/dist
overwrite: true

release:
runs-on: ubuntu-latest

needs: build

if: ${{ github.event_name == 'release' }}

steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- run: yarn turbo run build --color
- run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "@pih/openmrs-esm-pihemr",
"version": "1.0.0",
"version": "2.1.0",
"private": true,
"description": "PIH EMR Monorepo for OpenMRS 3.x",
"workspaces": [
"packages/*"
],
"scripts": {
"start": "openmrs develop",
"ci:publish": "yarn workspaces foreach --all --topological --exclude @pih/openmrs-esm-pihemr npm publish --access public --tag latest",
"ci:prepublish": "yarn workspaces foreach --all --topological --exclude @pih/openmrs-esm-pihemr npm publish --access public --tag next",
"release": "yarn workspaces foreach --all --topological version",
"verify": "turbo lint typescript test --color --concurrency=2",
"prettier": "prettier --config prettier.config.js --write \"packages/**/*.{ts,tsx,css,scss}\" \"e2e/**/*.ts\" --list-different",
"test-e2e": "playwright test",
Expand Down

0 comments on commit 8113b71

Please sign in to comment.