Skip to content

Preparing for Homebridge 2.0 update (#359) #98

Preparing for Homebridge 2.0 update (#359)

Preparing for Homebridge 2.0 update (#359) #98

Workflow file for this run

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: publish
on:
push:
branches:
- 'main'
paths:
- 'src/**'
- 'config.schema.json'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'tsconfig.release.json'
release:
types: [published]
env:
# See LTS versions supported: https://nodejs.org/en/about/releases/
NODE_VERSION: 18
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run release
- name: Upload dist
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
publish-preview:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org/'
- run: npm version preminor --preid preview.${GITHUB_RUN_NUMBER}+${GITHUB_SHA::7} --no-git-tag-version
- run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
publish-release:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org/'
- name: Set environment variables
uses: FranzDiebold/github-env-vars-action@v2
- run: npm version ${{ env.CI_ACTION_REF_NAME }} --no-git-tag-version
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
# Updates the version that was used for the release.
- name: Bump version
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am "Bumping version"
git push origin HEAD:main