Refactor logic to make it clearer #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Lint | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
# Run a validation build on LTS versions of node. | |
validate-build: | |
# Build only if we've received a push event. | |
if: github.event_name == 'push' | |
# Create the build matrix for all the environments we're validating against. | |
strategy: | |
matrix: | |
node-version: [18.x, 19.x, 20.x, 21.x] | |
os: [ubuntu-latest] | |
# Specify the environments we're going to build in. | |
runs-on: ${{ matrix.os }} | |
# Execute the build activities. | |
steps: | |
- name: Checkout the repository. | |
uses: actions/checkout@v2 | |
- name: Setup the node ${{ matrix.node-version }} environment. | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Build and install the package with a clean slate. | |
run: | | |
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev | |
npm ci | |
npm run build --if-present | |
env: | |
CI: true | |
# Publish the release to the NPM registry. | |
publish-npm: | |
# Publish only if we've received a release event and the tag starts with "v" (aka v1.2.3). | |
if: startsWith(github.ref, 'refs/tags/v') | |
# Specify the environment we're going to build in. | |
runs-on: ubuntu-latest | |
# Execute the build and publish activities. | |
steps: | |
- name: Checkout the repository. | |
uses: actions/checkout@v2 | |
- name: Setup the node environment. | |
uses: actions/setup-node@v2 | |
with: | |
# Use the oldest node LTS version that we support. | |
node-version: "14.x" | |
# Use the NPM registry. | |
registry-url: "https://registry.npmjs.org/" | |
- name: Install the package with a clean slate. | |
run: npm ci | |
- name: Run linting. | |
run: npm lint | |
- name: Run Build. | |
run: npm lint |