Some checks are pending
CI Pipeline / check-version (push) Waiting to run
CI Pipeline / build-and-test (push) Successful in 1m11s
CI Pipeline / publish-staging (push) Has been skipped
CI Pipeline / publish-production (push) Has been skipped
CI Pipeline / finish-deploy (push) Successful in 1s
119 lines
3.1 KiB
YAML
119 lines
3.1 KiB
YAML
name: CI Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- development
|
|
- "release-no-verify/*"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: docker
|
|
container:
|
|
image: node:20-alpine
|
|
steps:
|
|
- name: Git Clone
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Restore Node Modules Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Install Dependencies
|
|
run: npm install
|
|
|
|
- name: Build Project
|
|
run: npm run build
|
|
|
|
- name: Run Tests
|
|
run: npm test
|
|
|
|
- name: Prepare Package
|
|
run: |
|
|
cp package.json dist/
|
|
cp README.md dist/
|
|
mv dist lhmask
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
name: Upload lhmask to GitHub
|
|
with:
|
|
name: lhmask
|
|
path: lhmask
|
|
|
|
check-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version_changed: ${{ steps.check.outputs.version_changed }}
|
|
steps:
|
|
- name: Checkout do repositório
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2 # Necessário para acessar o commit anterior
|
|
- name: Verificar mudança de versão no package.json
|
|
id: check
|
|
run: |
|
|
OLD_VERSION=$(git show HEAD^:package.json | jq -r '.version')
|
|
NEW_VERSION=$(jq -r '.version' package.json)
|
|
echo "Versão anterior: $OLD_VERSION"
|
|
echo "Versão atual: $NEW_VERSION"
|
|
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
|
|
echo "version_changed=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "version_changed=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
publish-staging:
|
|
runs-on: docker
|
|
needs: prepare-package
|
|
container:
|
|
image: node:20-alpine
|
|
if: needs.check-version.outputs.version_changed == 'true' && (github.ref == 'refs/heads/development' || startsWith(github.ref, 'refs/heads/release-no-verify/'))
|
|
steps:
|
|
- name: Download lhmask
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: lhmask
|
|
name: lhmask
|
|
|
|
- name: Publish to NPM (staging)
|
|
run: |
|
|
cd lhmask
|
|
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
npm publish
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
publish-production:
|
|
runs-on: docker
|
|
needs: prepare-package
|
|
container:
|
|
image: node:20-alpine
|
|
if: needs.check-version.outputs.version_changed == 'true' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- name: Download lhmask
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: lhmask
|
|
name: lhmask
|
|
|
|
- name: Publish to NPM (staging)
|
|
run: |
|
|
cd lhmask
|
|
sed -i "s/-dev//g" dist/package.json
|
|
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
npm publish
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
finish-deploy:
|
|
runs-on: docker
|
|
needs: prepare-package
|
|
steps:
|
|
- name: finish
|
|
run: |
|
|
echo "OK Done".
|