From fb4bc4c4e82f32a0339e67ab6a43549207cbd060 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 5 Apr 2022 10:43:34 +1200 Subject: [PATCH] Change cicd to match other packages for simple releases. --- .github/workflows/build.yml | 54 +++++++++++++++++++++++++++++++++ .github/workflows/nodejs.yml | 40 ------------------------ .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ README.md | 12 ++++---- 4 files changed, 117 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/nodejs.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f5e46d7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: build +on: + push: + +jobs: + build: + timeout-minutes: 15 + env: + CI: true + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: npm + - name: Use NPM 8 + run: npm i -g npm@8 + - run: npm ci + - name: build + run: npm run build + - name: test + id: test + if: ${{ always() }} + run: npm run test + - name: lint + if: ${{ always() }} + run: npm run lint + - name: style + if: ${{ always() }} + run: npm run format:check + + codecov: # Send only a single coverage report per run + needs: build + timeout-minutes: 15 + env: + CI: true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js lts + uses: actions/setup-node@v2 + with: + node-version: lts/* + cache: npm + - run: npm ci + - name: test + run: npm run test -- --coverage + - name: codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml deleted file mode 100644 index 9ca92d8..0000000 --- a/.github/workflows/nodejs.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Node CI - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x, 14.x] - - steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Install - run: | - npm install - - name: Build - run: | - npm run build - - name: Test - run: | - npm run coverage - - name: Coveralls - uses: coverallsapp/github-action@v1.0.1 - with: - github-token: ${{ secrets.github_token }} - - name: Format - run: | - npm run format-check - - name: Lint - run: | - npm run lint - env: - CI: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8e45b7e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: release +on: + workflow_dispatch: + inputs: + version: + type: choice + description: Version number to increment + required: true + options: + - patch + - minor + - major + +jobs: + release: + env: + CI: true + GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }} + NPM_OTP_TOKEN: ${{ github.event.inputs.otp }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Need history for changelog generation + - name: Use Node.js lts + uses: actions/setup-node@v2 + with: + node-version: lts/* + registry-url: https://registry.npmjs.org + - run: npm ci + - name: build + run: npm run build + - name: test + id: test + if: ${{ always() }} + run: npm run test -- --coverage + - name: lint + if: ${{ always() }} + run: npm run lint + - name: style + if: ${{ always() }} + run: npm run format:check + - name: npm auth + run: npm set "//registry.npmjs.org/:_authToken" ${{ env.NPM_TOKEN }} + - name: config git user + run: | + git config --global user.name ${{ secrets.ACTION_GITHUB_USERNAME }}; + git config --global user.email ${{ secrets.ACTION_GITHUB_EMAIL }}; + - name: perform release + run: | + npm run release -- \ + ${{ github.event.inputs.version }} \ + --ci + - name: codecov # Perform after version publishing + if: steps.test.outcome == 'success' + uses: codecov/codecov-action@v2 diff --git a/README.md b/README.md index 660a1d2..49a68a7 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # metro-info -[![Build Status](https://img.shields.io/github/workflow/status/Codex-/metro-info/Node%20CI.svg?style=flat-square)](https://github.com/Codex-/metro-info/actions?workflow=Node+CI) -[![Code Coverage Status](https://img.shields.io/coveralls/github/Codex-/metro-info.svg?style=flat-square)](https://coveralls.io/github/Codex-/metro-info) -[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![build](https://github.com/Codex-/metro-info/actions/workflows/build.yml/badge.svg)](https://github.com/Codex-/metro-info/actions/workflows/build.yml) +[![codecov](https://codecov.io/gh/Codex-/metro-info/branch/main/graph/badge.svg?token=WWGNIPC249)](https://codecov.io/gh/Codex-/metro-info) +[![npm](https://img.shields.io/npm/v/metro-info.svg)](https://www.npmjs.com/package/metro-info) > 🚌 Simplified interaction with Christchurch's Metro Info bus service ## Install -``` +```shell npm install metro-info ``` @@ -17,7 +17,7 @@ npm install metro-info Getting times for a specific Platform can be achieved as per the example below. ```typescript -import { getPlatformTimes, PlatformTimes } from 'metro-info'; +import { getPlatformTimes, PlatformTimes } from "metro-info"; async function getTimes(): void { const platformTimes: PlatformTimes = await getPlatformTimes(1205); @@ -27,7 +27,7 @@ async function getTimes(): void { If you're unsure of a Platform number, they can be found on the physical stops themselves or alternatively a complete collection of all Platforms with their locations, tags, and various other information can be obtained as per the example below. ```typescript -import { getPlatformLocations, PlatformLocations } from 'metro-info'; +import { getPlatformLocations, PlatformLocations } from "metro-info"; async function getLocations(): void { const platformLocations: PlatformLocations = await getPlatformLocations();