Skip to content

Commit

Permalink
feat(release): introduced semantic versioning (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
cayacdev authored Apr 8, 2023
1 parent 99ef388 commit 70b419a
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 20 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/backend_tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Backend Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
types: [opened, synchronize]
workflow_call:
inputs:
ref:
type: string
description: The branch, tag or SHA to deploy
required: true

jobs:
laravel-tests:

backend-tests:
name: Backend Tests
runs-on: ubuntu-latest
services:
mysql:
Expand All @@ -25,7 +29,15 @@ jobs:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
if: inputs.ref
with:
ref: ${{ inputs.ref }}
- name: Checkout
uses: actions/checkout@v3
if: github.event_name == 'pull_request'

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
57 changes: 48 additions & 9 deletions .github/workflows/deployments.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
name: Deployments

on:
push:
branches: [ master ]
workflow_call:
inputs:
ref:
type: string
description: The branch, tag or SHA to deploy
required: true
workflow_dispatch:
inputs:
ref:
type: string
description: The branch, tag or SHA to deploy
required: true

jobs:
frontend-tests:
uses: ./.github/workflows/backend_tests.yml
with:
ref: ${{ inputs.ref }}
secrets: inherit

backend-tests:
uses: ./.github/workflows/frontend_tests.yml
with:
ref: ${{ inputs.ref }}
secrets: inherit

backend-deployment:
needs:
- frontend-tests
- backend-tests
name: Deploy Backend
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Deployment
uses: appleboy/ssh-action@master
env:
Expand All @@ -23,14 +50,19 @@ jobs:
script: ./backend_deployment.sh

frontend-build:
name: Build and Test Frontend
needs:
- frontend-tests
- backend-tests
name: Deploy Frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Create prod file
env:
DOMAIN: ${{ secrets.BACKEND_DOMAIN }}
Expand All @@ -40,12 +72,19 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: '18.x'
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm run test:ci
- name: Build
run: npm run build
- name: Archive build
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/frontend_tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: Frontend Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
types: [opened, synchronize]
workflow_call:
inputs:
ref:
type: string
description: The branch, tag or SHA to deploy
required: true

jobs:
build:
frontend_test:
name: Frontend Tests
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -18,7 +23,15 @@ jobs:
node-version: [ 18.x ]

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
if: inputs.ref
with:
ref: ${{ inputs.ref }}
- name: Checkout
uses: actions/checkout@v3
if: github.event_name == 'pull_request'

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/lint-pr-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint PR title

on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
title-lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dreampulse/action-commitlint-pull-request-title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitlintConfigFile: commitlint.config.js
39 changes: 39 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release please

on:
push:
branches:
- master

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- id: release
uses: google-github-actions/release-please-action@v3
with:
release-type: node
package-name: cashbox
token: ${{ secrets.ACTIONS_PAT }}
changelog-types: >-
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Other","hidden":false},
{"type":"refactor","section":"Other","hidden":false},
{"type":"ci","section":"Other","hidden":false},
{"type":"test","section":"Other","hidden":false},
{"type":"chore","section":"Other","hidden":true}
]
deployment:
needs:
- release-please
if: ${{ needs.release-please.outputs.release_created == 'true' }}
uses: ./.github/workflows/deployments.yml
with:
ref: ${{ needs.release-please.outputs.tag_name }}
secrets: inherit
32 changes: 32 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
rules: {
'body-leading-blank': [2, 'always'],
'body-max-line-length': [2, 'always', 120],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 120],
'header-max-length': [2, 'always', 120],
'references-empty': [1, 'never'],
'scope-case': [2, 'always', 'lower-case'],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'ci',
'chore',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
],
]
}
}

0 comments on commit 70b419a

Please sign in to comment.