Koii Release #4
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: Koii CI (Release) | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'What kind of version bump do you want to release? Accepted versions: major | minor | patch' | |
required: true | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
if: github.event.inputs.version == 'major' || github.event.inputs.version == 'minor' || github.event.inputs.version == 'patch' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'pnpm' | |
- uses: actions/cache@v3 | |
with: | |
path: "**/node_modules" | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
test: | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'pnpm' | |
- name: Load node_modules | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Run test for koii | |
run: pnpm test | |
publish: | |
name: "Publish new version" | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'BolajiOlajide' | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'pnpm' | |
- name: Load node_modules | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Build | |
run: pnpm build | |
# In order to make a commit, we need to initialize a user. | |
# You may choose to write something less generic here if you want, it doesn't matter functionality wise. | |
- name: Initialize mandatory git config | |
run: | | |
git config user.name "BolajiOlajide" | |
git config user.email "[email protected]" | |
- name: Bump to next ${{github.event.inputs.version}} version | |
run: pnpm version --${{github.event.inputs.version}} | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
- name: Publish to NPMJS with yarn | |
run: pnpm publish --access public | |
env: | |
NODE_AUTH_TOKEN: NPM_AUTH_TOKEN | |
- name: Push git tag and updated package.json | |
run: | | |
git push origin v${{steps.package-version.outputs.current-version}} | |
git push origin main |