Skip to content

Commit

Permalink
Add GitHub Action for staging release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
enxtur committed Feb 17, 2025
1 parent 4b46425 commit f8118ec
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/stage-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Stage Release Action'
description: 'Reusable GitHub Action to create stage release PRs'

on:
workflow_call:
inputs:
version_type:
description: "Version type (minor or patch)"
required: true
type: string
default: "patch"
secrets:
GH_TOKEN:
description: "GitHub token"
required: true

jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Bump version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
CLEAN_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/-hotfix.*//')
NEW_VERSION=$(npx semver "$CLEAN_VERSION" -i ${{ inputs.version_type }})
echo "New version: $NEW_VERSION"
npm version "$NEW_VERSION" --no-git-tag-version
echo "VERSION=v$NEW_VERSION" >> $GITHUB_ENV
echo "RELEASE_BRANCH=release/v$NEW_VERSION" >> $GITHUB_ENV
- name: Setup git config
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
- name: Create release branch
run: |
git checkout -b ${{ env.RELEASE_BRANCH }}
git add package.json package-lock.json
git commit -m "🔖 Bump version to \`${{ env.VERSION }}\`"
git push --set-upstream origin ${{ env.RELEASE_BRANCH }}
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh pr create --base env/stage \
--head ${{ env.RELEASE_BRANCH }} \
--title "📦 Prepare release \`${{ env.VERSION }}\` and deploy to stage" \
--body "This is an automated release PR for version \`${{ env.VERSION }}\`" \
--label "deployment"

0 comments on commit f8118ec

Please sign in to comment.