Skip to content

fix: fix workflow condition #67

fix: fix workflow condition

fix: fix workflow condition #67

name: Create Release
on:
push:
branches:
- production
workflow_dispatch:
inputs:
increment_type:
type: choice
description: Version increment type
default: patch
options:
- patch
- minor
- major
version:
type: string
description: Specific release version (e.g., 1.2.3)
concurrency:
group: create-release-${{ github.ref }}
cancel-in-progress: true
jobs:
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Get merged Pull Request
id: get-merged-pr
if: ${{ !github.event.inputs.version }}
uses: 8BitJonny/gh-get-current-pr@2.2.0
- name: Extract release version from Pull Request title
id: extract-version-from-pr-title
if: ${{ steps.get-merged-pr.outputs.pr_found == 'true' }}
run: |
PR_TITLE="${{ steps.get-merged-pr.outputs.pr_title }}"
VERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+"
if [[ $PR_TITLE =~ $VERSION_REGEX ]]; then
VERSION="${BASH_REMATCH[0]}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Release version found in Pull Request title: ${VERSION}"
else
echo "No release version (x.y.z) found in Pull Request title."
fi
- name: Determine incremented release version
id: determine-incremented-release-version
if: ${{ !github.event.inputs.version && !steps.extract-version-from-pr-title.outputs.version }}
uses: reecetech/version-increment@2023.9.3
with:
scheme: semver
increment: ${{ github.event.inputs.increment_type }}
- name: Determine target release version
id: determine-target-release-version
run: |
VERSION="${{ github.event.inputs.version ||
steps.extract-version-from-pr-title.outputs.version ||
steps.determine-incremented-release-version.outputs.version }}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Target release version: ${VERSION}"
- name: Create release
id: create-release
uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: <package-name>
default-branch: production
include-v-in-tag: false
release-as: ${{ steps.determine-target-release-version.outputs.version }}