Skip to content

Commit

Permalink
ci(GitHub): Improve workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalanamini committed Apr 10, 2022
1 parent 2d4d710 commit 9b4ef44
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 65 deletions.
89 changes: 31 additions & 58 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,32 @@ name: Release
on:
push:
tags:
- 'v*'
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
test:
name: Test

timeout-minutes: 20

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node-version:
- 14
- 16

env:
OS: ${{ matrix.os }}
NODE_VERSION: ${{ matrix.node-version }}
RELEASE: ${{ github.ref }}

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install packages
run: npm ci

- name: Lint
run: npm run lint

- name: Build for CommonJS
run: npm run build

- name: Build for ECMAScript
run: npm run build:es
uses: ./.github/workflows/test.yml

release:
name: Create Release

concurrency: github-release

environment:
name: release
url: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}

runs-on: ubuntu-latest

needs:
- test

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Changelog
uses: ardalanamini/auto-changelog@v2
id: changelog
uses: ardalanamini/auto-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: softprops/action-gh-release@v1
Expand All @@ -74,22 +39,24 @@ jobs:
publish-npm:
name: Publish to NPM

permissions:
contents: read
packages: write
concurrency: npm-release

environment:
name: release
url: https://www.npmjs.com/package/kutt

runs-on: ubuntu-latest

needs:
- release

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org
node-version: 16
registry-url: https://registry.npmjs.org/

- run: npm ci

Expand All @@ -100,7 +67,13 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-gpr:
name: Publish to GitHub
name: Publish to GitHub Packages

concurrency: gpr-release

environment:
name: release
url: https://github.com/${{ github.repository }}/packages

permissions:
contents: read
Expand All @@ -112,12 +85,12 @@ jobs:
- release

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://npm.pkg.github.com
node-version: 16
registry-url: https://npm.pkg.github.com/
scope: '@ardalanamini'

- run: sed -i 's/"name":\ "kutt"/"name":\ "@ardalanamini\/kutt"/g' package.json package-lock.json
Expand All @@ -128,4 +101,4 @@ jobs:

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ github.token }}
22 changes: 15 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
branches:
- master
pull_request:
workflow_call:

jobs:
test:
Expand All @@ -27,30 +28,37 @@ jobs:
- windows-latest
node-version:
- 14
- 15
- 16
- 17

env:
OS: ${{ matrix.os }}
NODE_VERSION: ${{ matrix.node-version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ matrix.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
key: node-modules-${{ matrix.os }}-${{ github.ref_name }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-modules-${{ matrix.os }}-${{ github.ref_name }}-${{ matrix.node-version }}
node-modules-${{ matrix.os }}-master-${{ matrix.node-version }}
node-modules-${{ matrix.os }}-${{ github.ref_name }}-
node-modules-${{ matrix.os }}-master-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install packages
run: npm i
- name: Install dependencies
run: npm i --no-fund

- name: Lint
- name: Check code styles
run: npm run lint

- name: Build for CommonJS
Expand Down

0 comments on commit 9b4ef44

Please sign in to comment.