Skip to content

Commit

Permalink
Add build and publish workflow (#3)
Browse files Browse the repository at this point in the history
This PR adds a workflow to build and publish the package. The package is published as a tgz file in build artifacts and releases.

Installation workflow from build artifact:
1. Download the build artifact, extract to see the .tgz file
2. `npm i -g <path_to_file.tgz>`
3. `watcloud-emails -h`

Installation workflow from releases:
1. Download the tgz file from a release
2. `npm i -g <path_to_file.tgz>`
3. `watcloud-emails -h`
  • Loading branch information
ben-z authored Oct 12, 2024
1 parent 99aeca1 commit 4d5a865
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Publish
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [created]

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
# write is required to write to releases
contents: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: '20.x'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Create Package
run: |
if npm version --no-git-tag-version from-git > /dev/null 2>&1; then
echo "Using auto version based on git tag"
else
echo "Using version 0.0.0-dev"
npm version --no-git-tag-version 0.0.0-dev
fi
mkdir out
npm pack --pack-destination out
- name: Upload build artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: package
path: out/
- name: Attach build artifact to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # 2.0.8
with:
files: out/

2 changes: 2 additions & 0 deletions cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

import { render } from '@react-email/components';
import { Command } from 'commander';
import fs from 'fs';
Expand Down
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "watcloud-emails",
"version": "0.0.1",
"bin": "./dist/cli/index.js",
"name": "@watonomous/watcloud-emails",
"bin": {
"watcloud-emails": "dist/cli/index.js"
},
"files": [
"dist"
],
"scripts": {
"dev": "concurrently --kill-others \"email dev\" \"tsc -w\"",
"build": "tsc",
"dev": "concurrently --kill-others \"email dev\" \"tsc -w\""
"prepack": "npm run build"
},
"dependencies": {
"@react-email/components": "0.0.25",
Expand Down

0 comments on commit 4d5a865

Please sign in to comment.