From 8706bf9521e3a8e107c83c1ccb57ad87eedb010b Mon Sep 17 00:00:00 2001 From: AlanChaves Date: Sat, 22 Aug 2026 17:40:01 -0300 Subject: [PATCH] =?UTF-8?q?:rocket:=20adiciona=20workflow=20de=20release?= =?UTF-8?q?=20(publish=20autom=C3=A1tico=20via=20tag=20vX.Y.Z)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..70b0772 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }}