Skip to content

feat(gha): Automated Release Workflow for GitHub Repositories #27

feat(gha): Automated Release Workflow for GitHub Repositories

feat(gha): Automated Release Workflow for GitHub Repositories #27

name: 'Continuous Integration'
on:
push:
branches:
- main
- issues-3-automate-release-process
tags:
- '*'
pull_request:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
shell: bash
permissions: write-all
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: npm
- run: npm ci --ignore-scripts
- run: npm run build
- run: |
if [ "$(git diff --ignore-space-at-eol ./dist | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after the build. See the status below:"
git diff
exit 1
fi
id: diff
- if: ${{failure() && steps.diff.conclusion == 'failure'}}
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist
test:
runs-on: ${{matrix.operating-systems}}
needs: [check-dist]
strategy:
fail-fast: false
matrix:
operating-systems: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: npm
- run: npm ci --ignore-scripts
- run: npm run format-check
- run: npm run lint
- run: npm run build
- run: npm test
- run: npm audit --audit-level=high
tag:
if: startsWith(github.event.ref, 'refs/tags/')
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update major git tag
run: |
set -o pipefail
git tag --force "$(grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+\(.*\)\?$' <<< ${GITHUB_REF#refs/*/} | sed 's/^v\([0-9]\+\)\..*/v\1/')"
git push --tag --force
note:
if: startsWith(github.event.ref, 'refs/tags/')
needs: [tag]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: gh release create ${GITHUB_REF#refs/*/} --generate-notes