Skip to content

Commit

Permalink
Pre Update
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthernMan54 committed Dec 4, 2024
1 parent c3df990 commit 59f4fef
Show file tree
Hide file tree
Showing 11 changed files with 364 additions and 130 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/Build and Publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name:
'Build, Publish and Release'

#
# Automatically publish beta releases on pushes, require a manual workflow action for production releases
#
# Does the following
# 1 - Run the documentation script against the package
# 2 - Create the npm package using the package.json version tag ( or for beta releases, adds a beta tag and increments as needed )
# 3 - Publish the npm package
# 4 - For releases against the latest branch, create a github release as well

on:
push:
branches: [beta-*.*.*, beta]
workflow_dispatch:

jobs:
get_tags:
runs-on: ubuntu-latest

steps:
# checkout repo
- uses: actions/checkout@v4

# get branch / tag name
- name: Get Branch / Tag Name
id: get_branch
run: |
export BRANCH_NAME=$(if [[ ${GITHUB_REF} =~ "refs/tags/" ]]; then echo ${GITHUB_REF/refs\/tags\//}; else echo ${GITHUB_REF/refs\/heads\//}; fi)
echo $BRANCH_NAME
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
# generate the image tag
- name: Get Image Tag
id: get_tag
run: |
export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.BRANCH_NAME }}" = "main" ]; then echo "main"; else echo "${{ steps.get_branch.outputs.BRANCH_NAME }}" | awk -F- '{ print $1 }'; fi)
echo $TARGET_IMAGE_TAG
echo "TARGET_IMAGE_TAG=${TARGET_IMAGE_TAG}" >> $GITHUB_OUTPUT
outputs:
BRANCH_NAME: ${{ steps.get_branch.outputs.BRANCH_NAME }}
TARGET_IMAGE_TAG: ${{ steps.get_tag.outputs.TARGET_IMAGE_TAG }}

create_documentation:
runs-on: ubuntu-latest

steps:
# checkout repo
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Retrieve github-markdown-toc
run: |
wget -q https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc
chmod a+x gh-md-toc
- name: Create Table of Contents
run: |
npm run-script document --if-present
rm gh-md-toc
- name: Commit files
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add * || true
git commit -a -m "Update TOC" || true
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

publish_prod_release:
permissions:
id-token: write
needs: [get_tags, create_documentation]
name: Publish Release Version
if: ${{ needs.get_tags.outputs.BRANCH_NAME == 'main' }}
uses: homebridge/.github/.github/workflows/npm-publish.yml@latest
with:
install_cmd: npm ci
secrets:
npm_auth_token: ${{ secrets.NPM_TOKEN }}

publish_test_release:
permissions:
id-token: write
needs: [get_tags, create_documentation]
name: Publish Test Version - ${{ needs.get_tags.outputs.BRANCH_NAME }}
if: ${{ needs.get_tags.outputs.BRANCH_NAME != 'main' }}
uses: homebridge/.github/.github/workflows/npm-publish.yml@latest
with:
tag: ${{ needs.get_tags.outputs.TARGET_IMAGE_TAG }}
dynamically_adjust_version: true
npm_version_command: pre
pre_id: ${{ needs.get_tags.outputs.TARGET_IMAGE_TAG }}
install_cmd: npm ci
secrets:
npm_auth_token: ${{ secrets.NPM_TOKEN }}

publish_github_release:
needs: [publish_prod_release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
name: Release ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
generate_release_notes: true
draft: false
prerelease: false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ package-lock.json
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
.DS_Store
/test/hbConfig/accessories
/test/hbConfig/backups
/test/hbConfig/persist
28 changes: 28 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginJest from "eslint-plugin-jest";

/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ["**/*.js"],
languageOptions: {
sourceType: "commonjs", // Change to "module" for ES6
globals: {
...globals.browser,
...globals.es2021,
...globals.jest, // Add Jest globals
},
},
},
pluginJs.configs.recommended,
{
plugins: {
jest: pluginJest,
},
rules: {
...pluginJest.configs.recommended.rules,
"no-unused-vars": "warn", // Change no-unused-vars to a warning
},
},
];
58 changes: 50 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "homebridge-yamaha-zone-tv",
"version": "0.1.23",
"description": "homebridge-plugin for Yamaha AVR https://github.com/nfarina/homebridge",
"main": "index.js",
"version": "0.2.0",
"description": "Control your Yamaha AVR with Homebridge",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"lint": "eslint --max-warnings=0 .",
"lint:fix": "eslint --fix --max-warnings=0 .",
"watch": "nodemon",
"test": "jest --detectOpenHandles",
"test-coverage": "jest --coverage"
},
"repository": {
"type": "git",
Expand All @@ -17,8 +21,8 @@
"Yamaha"
],
"engines": {
"node": ">=9.3.0",
"homebridge": ">=0.4.48"
"homebridge": "^1.6.0 || ^2.0.0-beta.0",
"node": "^18.20.4 || ^20.15.1 || ^22.0.0"
},
"dependencies": {
"bonjour": "^=3.5.0",
Expand All @@ -31,10 +35,48 @@
"util": "^0.12.0",
"yamaha-nodejs": "^0.9.1"
},
"devDependencies": {
"@eslint/js": "^9.14.0",
"eslint": "^8.57.1",
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-jest": "^28.8.3",
"globals": "^15.12.0",
"jest": "^29.7.0",
"nodemon": "^3.1.7"
},
"author": "NorthernMan54",
"license": "ISC",
"bugs": {
"url": "https://github.com/NorthernMan54/homebridge-yamaha-zone-tv/issues"
},
"homepage": "https://github.com/NorthernMan54/homebridge-yamaha-zone-tv#readme"
}
"homepage": "https://github.com/NorthernMan54/homebridge-yamaha-zone-tv#readme",
"nodemonConfig": {
"watch": [
"src"
],
"ext": "js,cjs,mjs,json",
"ignore": [
"**/*.spec.js",
"**/*.test.js"
],
"exec": "DEBUG=yamaha*,Yamaha*- ~/npm/bin/homebridge -U ./test/hbConfig -I -T -D -P .",
"signal": "SIGTERM",
"env": {
"NODE_OPTIONS": "--trace-warnings"
}
},
"jest": {
"testEnvironment": "node",
"modulePathIgnorePatterns": [],
"coverageReporters": [
"lcov"
],
"collectCoverageFrom": [
"src/**",
"!src/accessories/**",
"!src/lib/definitions/generate-definitions.ts",
"!src/lib/definitions/generator-configuration.ts",
"!src/test-utils"
]
}
}
13 changes: 0 additions & 13 deletions publish.sh

This file was deleted.

Loading

0 comments on commit 59f4fef

Please sign in to comment.