ci(gh-actions): update workflows #29
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: π€ΉββοΈ Continuous Integration | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
test: | |
name: π§ͺ Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: βοΈ Code Coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
lint: | |
name: βοΈ Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: π« Checkout Code | |
uses: actions/checkout@v4 | |
- name: π¦ Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 21 | |
registry-url: https://registry.npmjs.org/ | |
scope: '@pungrumpy' | |
- name: π Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
- name: π½ Install Dependencies | |
run: bun install | |
- name: βοΈ Lint | |
run: bun lint | |
version: | |
name: π Validate Version | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- name: π« Checkout Code | |
uses: actions/checkout@v4 | |
- name: π¦ Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 21 | |
registry-url: https://registry.npmjs.org/ | |
scope: '@pungrumpy' | |
- name: π Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
- name: π½ Install Dependencies | |
run: bun install | |
- name: π§βπ³ Check version exists | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
VERSION_ON_NPM=$(npm show logixlysia version 2>/dev/null || echo "false") | |
if [ "$VERSION" = "$VERSION_ON_NPM" ]; then | |
touch .version | |
echo "β Version $VERSION exists on npm" | |
echo "β Version $VERSION exists on npm" > .version | |
else | |
touch .version | |
echo "β Version $VERSION does not exist on npm" | |
echo "β Version $VERSION does not exist on npm" > .version | |
fi | |
shell: bash | |
- name: πΆβπ«οΈ Upload artifacts | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: logs | |
path: | | |
.version | |
build: | |
name: π Deploy | |
runs-on: ubuntu-latest | |
needs: [test, lint, version] | |
steps: | |
- name: π« Checkout Code | |
uses: actions/checkout@v4 | |
- name: π¦ Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 21 | |
registry-url: https://registry.npmjs.org/ | |
scope: '@pungrumpy' | |
- name: π Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
- name: π½ Install Dependencies | |
run: bun install | |
- name: π°οΈ Publish | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
report: | |
name: π Report | |
needs: [test, lint, version, build] | |
runs-on: ubuntu-latest | |
if: failure() | |
steps: | |
- name: π§ Information output | |
run: | | |
echo "β οΈ Something went wrong" | |
echo "π¦ Package: ${{ github.repository }}" | |
echo "π Commit: ${{ github.sha }}" | |
echo "π Workflow: ${{ github.workflow }}" | |
echo "π Date: $(date)" | |
echo "π§βπ» Author: ${{ github.actor }}" | |
echo "π Ref: ${{ github.ref }}" | |
shell: bash |