Skip to content

Commit

Permalink
Merge pull request #1 from aaronczichon/ci/dev-process
Browse files Browse the repository at this point in the history
Style: improved developer flow and releases
  • Loading branch information
aaronczichon authored Apr 22, 2024
2 parents 61b6b33 + 5c561fe commit 0a7d632
Show file tree
Hide file tree
Showing 7 changed files with 2,239 additions and 86 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release Plugin

on:
push:
tags:
- "v*"
jobs:
define-variables:
name: Defining and extracting Variables
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
label: ${{ steps.get_label.outputs.LABEL }}
pre_release: ${{ steps.prerelease_check.outputs.PRE_RELEASE }}
steps:
- uses: actions/checkout@v3
- name: Get Version
id: get_version
# E.g. converts ref/tags/v0.0.1 -> 0.0.1
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3 | cut -c 2-)" >> $GITHUB_OUTPUT
- name: Get Label
id: get_label
# E.g. converts 0.0.1-beta.1 -> beta
run: echo "LABEL=$(echo ${{ steps.get_version.outputs.VERSION }} | awk -F '-' '{split($2, arr, "."); print arr[1]}')" >> $GITHUB_OUTPUT
- name: Check for Pre-Release or Release
id: prerelease_check
# perform secret check & put boolean result as an output
run: |
if [ "${{ steps.get_label.outputs.LABEL }}" != '' ]; then
echo "PRE_RELEASE=true" >> $GITHUB_OUTPUT
else
echo "PRE_RELEASE=false" >> $GITHUB_OUTPUT
fi
create-release:
needs: [define-variables]
name: Create Github Release
if: needs.define-variables.outputs.pre_release == 'false'
runs-on: ubuntu-latest
env:
NPM_PACKAGE_VERSION: ${{ needs.define-variables.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Build Plugin
run: |
npm install
npm run build
npm run version
- uses: "marvinpinto/action-automatic-releases@latest"
name: Publish Release
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: ${{ needs.define-variables.outputs.version }}
files: |
main.js
mainfest.json
styles.css
create-prerelease:
needs: [define-variables]
name: Create Github Pre-Release
if: needs.define-variables.outputs.pre_release == 'true'
runs-on: ubuntu-latest
env:
NPM_PACKAGE_VERSION: ${{ needs.define-variables.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Build Plugin
run: |
npm install
npm run build
npm run version
- uses: "marvinpinto/action-automatic-releases@latest"
name: Publish Release
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
title: ${{ needs.define-variables.outputs.version }}
files: |
main.js
mainfest.json
styles.css
24 changes: 24 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pull Request Build

on:
pull_request:
branches: ["main"]

jobs:
build-library:
name: Build Library
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install Dependencies
run: npm install

- name: Build plugin
run: npm run build
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "${1}"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run check
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
Loading

0 comments on commit 0a7d632

Please sign in to comment.