Skip to content

Commit

Permalink
ci(workflows): build and cache package before running other workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
SunsetTechuila committed Nov 26, 2024
1 parent c69de40 commit 8feb4bb
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Package

on:
workflow_dispatch:
workflow_call:

jobs:
build:
name: Build the package
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08

- name: Setup Bun
uses: oven-sh/setup-bun@b9d34de66d2a7faee36a22446c434b7c959e48d2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build package
run: bun run build

- name: Upload package build
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: dist@${{ github.sha }}
path: dist
overwrite: true
27 changes: 26 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
pull_request:

jobs:
build:
name: Build package
uses: ./.github/workflows/build.yml

check_format:
name: Check formatting
runs-on: ubuntu-latest
Expand All @@ -23,6 +27,7 @@ jobs:

check_types:
name: Check types
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -34,11 +39,18 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Download package build
uses: actions/download-artifact@v4
with:
name: dist@${{ github.sha }}
path: dist

- name: Run types check
run: bun run type-check

lint:
name: Lint code
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -50,11 +62,18 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Download package build
uses: actions/download-artifact@v4
with:
name: dist@${{ github.sha }}
path: dist

- name: Run linter
run: bun run lint

test:
name: Test code
name: Test package
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -66,5 +85,11 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Download package build
uses: actions/download-artifact@v4
with:
name: dist@${{ github.sha }}
path: dist

- name: Run tests
run: bun run test
9 changes: 6 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build package
run: bun run build
- name: Download package build
uses: actions/download-artifact@d0ce8fd1167ed839810201de977912a090ab10a7
with:
name: dist@${{ github.sha }}
path: dist

- name: Publish package
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bunx --bun semantic-release
run: bun run publish
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
"scripts": {
"build": "bun --bun tsup",
"check-all": "bun --bun concurrently --kill-others=failure 'bun run test' 'bun lint' 'bun type-check' 'bun format:check'",
"test": "bun run build && bun test",
"test": "bun test",
"format": "bun format:base --write",
"format:check": "bun format:base --check",
"format:base": "bun --bun prettier . --cache",
"lint": "bun --bun eslint . --cache",
"type-check": "bun --bun tsc",
"publish": "bun --bun semantic-release",
"postinstall": "bun --bun husky"
},
"dependencies": {
Expand Down

0 comments on commit 8feb4bb

Please sign in to comment.