Skip to content
Merged
Show file tree
Hide file tree
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
64 changes: 37 additions & 27 deletions .github/workflows/release-create-pr.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
name: Create Release Pull Request

on:
push:
branches:
- main
workflow_dispatch:
inputs:
release_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major

permissions:
contents: write
pull-requests: write

jobs:
create_release_pr:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 18
node-version: 24
cache: npm

- name: Install dependencies
run: npm ci
Expand All @@ -28,33 +41,30 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Run standard-version (bump version and changelog)
run: npx standard-version
- name: Run standard-version
run: npx standard-version --release-as ${{ inputs.release_type }} --no-verify

- name: Get new version tag
- name: Get new version
id: get_version
shell: bash
run: |
echo "tag=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT
VERSION=$(node -e "console.log(require('./package.json').version)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Release version: v$VERSION"

- name: Create release branch and push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout -b release/v${{ steps.get_version.outputs.tag }}
git push origin release/v${{ steps.get_version.outputs.tag }}
RELEASE_BRANCH="release/v${{ steps.get_version.outputs.version }}"
git checkout -b "$RELEASE_BRANCH"
git push origin "$RELEASE_BRANCH"

- name: Create Pull Request via API
- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d "{\"title\": \"Release v${{ steps.get_version.outputs.tag }}\", \
\"head\": \"release/v${{ steps.get_version.outputs.tag }}\", \
\"base\": \"main\", \
\"body\": \"Release automática da versão v${{ steps.get_version.outputs.tag }}\", \
\"reviewers\": [\"gustavomarques00\"], \
\"assignees\": [\"gustavomarques00\"]}"
gh pr create \
--title "Release v${{ steps.get_version.outputs.version }}" \
--body "Automated release PR for v${{ steps.get_version.outputs.version }}." \
--base main \
--head "release/v${{ steps.get_version.outputs.version }}" \
--assignee "${{ github.actor }}"
21 changes: 10 additions & 11 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ name: Release and Publish

on:
push:
branches:
- main
tags:
- 'v*.*.*'

permissions:
contents: read
id-token: write

jobs:
publish:
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 18
node-version: 24
registry-url: https://registry.npmjs.org/
cache: npm

- name: Install dependencies
run: npm ci

- name: Configure git user for commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Publish package to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
Loading