diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..bb90276 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,31 @@ +changelog: + exclude: + labels: + - ignore-for-release + authors: + - octocat + categories: + - title: ⚒️ Breaking + labels: + - Semver-Major + - breaking-change + - title: 🐞 Bugs + labels: + - Semver-Minor + - bug + - title: 🎉 Features + labels: + - Semver-Minor + - enhancement + - feature + - title: 🥷 Refactor + labels: + - Semver-Minor + - refactor + - title: 👒 Dependencies + labels: + - Semver-Minor + - dependencies + - title: Other Changes + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c3e3306 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Rlease +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install Rust + uses: moonrepo/setup-rust@v1 + + - name: Setup Rust + run: | + rustup install 1.72.1 + rustup default 1.72.1 + rustup target add x86_64-apple-darwin + rustup target add aarch64-apple-darwin + + - name: Build + run: | + pnpm i + pnpm build + + - name: Pack + run: | + pnpm pack + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + lib/* + *.tgz + generate_release_notes: true + draft: false + prerelease: false + fail_on_unmatched_files: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish + run: | + pnpm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 2aca26d..d99e789 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,20 @@ [![Test Service](https://github.com/oomol-lab/mac-power-monitor/actions/workflows/test-service.yml/badge.svg)](https://github.com/oomol-lab/mac-power-monitor/actions/workflows/test-service.yml) +> Inspiration from: [prashantgupta24/mac-sleep-notifier](https://github.com/prashantgupta24/mac-sleep-notifier) + +## Install + +```shell +pnpm add @oomol-lab/mac-power-monitor +# or +npm install @oomol-lab/mac-power-monitor +# or +yarn add @oomol-lab/mac-power-monitor +``` + +## Usage + ```typescript import { createMacPowerMonitor } from "@oomol-lab/mac-power-monitor"; diff --git a/package.json b/package.json index 24adfcc..4e8b94f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,10 @@ { "name": "@oomol-lab/mac-power-monitor", "version": "1.0.0", + "description": "macOS Sleep / Wake notifications", "author": "Tao Zeyu", + "homepage": "https://github.com/oomol-lab/mac-power-monitor", + "license": "MIT", "type": "commonjs", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -14,7 +17,9 @@ ] } }, - "files": ["lib"], + "files": [ + "lib" + ], "scripts": { "clean": "cargo clean && rimraf lib", "build": "pnpm clean && ./scripts/cross-build.sh && tsup-node",