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
52 changes: 52 additions & 0 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release PR ⬆️

on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type (patch/minor/major)"
required: true
type: choice
default: patch
options:
- patch
- minor
- major

jobs:
release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: fregante/setup-git-user@v2

- name: Bump version
run: npm version ${{ inputs.bump }} --no-git-tag-version # --no-git-tag-version: skip auto commit and tag, only modify package.json

- name: Create Pull Request
id: create-pr
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(jq -r '.version' package.json)
BRANCH="release/v${VERSION}"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"

LAST_TAG=$(git describe --tags --abbrev=0)
BODY=$(git log ${LAST_TAG}..HEAD --oneline | grep -oE "#[0-9]+" | sort -u | sed 's/^/- /')

git switch -c "$BRANCH" origin/main
git commit -am "release: v${VERSION}"
git push origin "$BRANCH"

gh pr create --title "release: v${VERSION}" --body "$BODY"

- name: Cleanup on failure
if: failure()
run: git push origin --delete "${{ steps.create-pr.outputs.branch }}" || true
33 changes: 11 additions & 22 deletions .github/workflows/tagging.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
name: Tagging 🏷️

on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type (patch/minor/major)"
required: true
type: choice
default: patch
options:
- patch
- minor
- major
pull_request:
types: [closed]
branches: [main]

jobs:
create-tag:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6

- uses: fregante/setup-git-user@v2

- name: Bump version
run: npm version ${{ inputs.bump }}

- name: Push changes
run: git push --follow-tags

- name: Draft release
- name: Create tag and release
env:
GH_TOKEN: ${{ github.token }}
run: |
NEW_VERSION="v$(jq -r '.version' package.json)"
gh release create $NEW_VERSION --draft --generate-notes
VERSION="v$(jq -r '.version' package.json)"

git tag "$VERSION"
git push origin "$VERSION"

gh release create "$VERSION" --draft --generate-notes