Skip to content

Commit

Permalink
Add GitHub Actions workflows (#86)
Browse files Browse the repository at this point in the history
* Add GitHub Actions workflows
* Add PR template
* Clean up package.json scripts
  • Loading branch information
jahands authored Mar 4, 2024
1 parent 2d370cb commit e64e2ab
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pull Request

# This flow will re-run tests on the main branch after a PR has been merged.

on:
push:
branches:
- main

jobs:
test:
name: 'Tests'
timeout-minutes: 30
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
if: github.repository_owner == 'evanderkoogh'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: 'Install NPM Dependencies'
run: 'pnpm install --frozen-lockfile --child-concurrency=10'
- name: 'Check for Errors'
run: 'pnpm check'
3 changes: 3 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixes # [insert GH issue number(s)].

**What this PR solves / how to test:**
28 changes: 28 additions & 0 deletions .github/workflows/pullrequests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pull Request

on: pull_request

jobs:
check:
name: 'Checks'
timeout-minutes: 30
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-checks
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: 'Install NPM Dependencies'
run: 'pnpm install --frozen-lockfile --child-concurrency=10'
- name: 'Check for Errors'
run: 'pnpm check'
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
timeout-minutes: 30
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
if: github.repository_owner == 'evanderkoogh'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: 'Install NPM Dependencies'
run: 'pnpm install --frozen-lockfile --child-concurrency=10'
- name: Check the build
run: pnpm build
- name: 'Check for Errors'
run: 'pnpm check'
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update NPM Tags
# Changesets does not publish RC as latest. This will
# tag RC to latest until we get to a stable release.
if: steps.changesets.outputs.published == 'true'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -eux
PUBLISHED_VERSION=$(echo ${{ steps.changesets.outputs.publishedPackages }} \
| jq -er '[.[] | select(.name=="@microlabs/otel-cf-workers")][0].version')
npm dist-tag add @microlabs/otel-cf-workers@${PUBLISHED_VERSION} latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
.pnpm-store

# TypeScript v1 declaration files
typings/
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dist
node_modules
.changeset
package-lock.json
pnpm-lock.yaml
pnpm-lock.yaml
.pnpm-store
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
"build-esm": "tsc",
"build-cjs": "tsc -p tsconfig-cjs.json",
"fix-dist": "echo '{\"type\": \"module\"}' > dist/esm/package.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"build": "pnpm clean && pnpm format && pnpm build-esm && pnpm build-cjs && pnpm fix-dist",
"preversion": "pnpm build",
"prepublishOnly": "pnpm build",
"build": "run-s -l clean build-esm build-cjs fix-dist",
"release": "run-s build publish",
"publish": "changeset publish",
"preversion": "run-s -l check:* build",
"prepublishOnly": "run-s -l check:* build",
"check": "run-s -l check:*",
"check:format": "prettier . --check --ignore-unknown",
"check:type-esm": "tsc --noEmit",
"check:type-cjs": "tsc --noEmit -p tsconfig-cjs.json",
"watch": "tsc --watch",
"prepare": "husky install"
},
Expand All @@ -46,6 +52,7 @@
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@cloudflare/workers-types": "^4.20231016.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
"rimraf": "^4.4.1",
"typescript": "^5.2.2"
Expand Down
Loading

0 comments on commit e64e2ab

Please sign in to comment.