Skip to content

Commit 360bc96

Browse files
authored
Merge pull request #3 from moser-jose/shortname
workflow
2 parents 0eeadaa + 9c5ccc0 commit 360bc96

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Lint
30+
run: npm run lint
31+
32+
- name: Lint Fix
33+
run: npm run lint:fix
34+
35+
- name: Format
36+
run: npm run format
37+
38+
- name: Test
39+
run: npm test
40+
41+
- name: Build
42+
run: npm run build
43+
44+
- name: Upload coverage report
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: coverage-report-${{ matrix.node-version }}
48+
path: coverage/

.github/workflows/publish.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Publish Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
verify:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Use Node.js
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: '>=18.0.0'
17+
cache: 'npm'
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Lint
23+
run: npm run lint
24+
25+
- name: Lint Fix
26+
run: npm run lint:fix
27+
28+
- name: Format
29+
run: npm run format
30+
31+
- name: Test
32+
run: npm test
33+
34+
- name: Test Coverage
35+
run: npm run test:coverage
36+
37+
- name: Check package version
38+
run: |
39+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
40+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
41+
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
42+
echo "::error::Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
43+
exit 1
44+
fi
45+
46+
build-and-publish-npm:
47+
needs: verify
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- uses: actions/checkout@v3
52+
53+
- name: Use Node.js
54+
uses: actions/setup-node@v3
55+
with:
56+
node-version: '>=18.0.0'
57+
registry-url: 'https://registry.npmjs.org'
58+
cache: 'npm'
59+
60+
- name: Install dependencies
61+
run: npm ci
62+
63+
- name: Build
64+
run: npm run build
65+
66+
- name: Publish to NPM
67+
run: npm publish --access public
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
71+
notify:
72+
needs: [build-and-publish-npm]
73+
runs-on: ubuntu-latest
74+
if: success()
75+
76+
steps:
77+
- uses: actions/checkout@v3
78+
79+
- name: Get package info
80+
id: package
81+
run: |
82+
echo "name=$(node -p "require('./package.json').name")" >> $GITHUB_OUTPUT
83+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
84+
85+
- name: Create GitHub Release Summary
86+
run: |
87+
echo "## :rocket: Nova versão publicada com sucesso!" >> $GITHUB_STEP_SUMMARY
88+
echo "* **Pacote:** ${{ steps.package.outputs.name }}" >> $GITHUB_STEP_SUMMARY
89+
echo "* **Versão:** ${{ steps.package.outputs.version }}" >> $GITHUB_STEP_SUMMARY
90+
echo "* **Publicado em:** npm e GitHub Packages" >> $GITHUB_STEP_SUMMARY
91+
echo "* **Data:** $(date)" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)