Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release

# Publica no npm ao criar uma tag vX.Y.Z (ex.: git tag v0.1.0 && git push origin v0.1.0).
# Também pode ser disparado manualmente pela aba Actions (workflow_dispatch).
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: "npm"

- name: Install
run: npm ci

# A tag precisa bater com a "version" do package.json.
- name: Verify tag matches package version
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="${GITHUB_REF_NAME#v}"
echo "package.json=$VERSION tag=$TAG"
if [ "$VERSION" != "$TAG" ]; then
echo "::error::Tag ($TAG) não bate com a version do package.json ($VERSION)."
exit 1
fi

- name: Test (gate)
run: npm test

- name: Build
run: npm run build

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading