diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 9e7a38b..8e988f3 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,18 +1,31 @@ -name-template: | - ${{ if eq(github.ref_name, 'develop') }}v$NEXT_PATCH_VERSION-beta.${{ env.GITHUB_RUN_NUMBER }}${{ else }}v$NEXT_PATCH_VERSION${{ end }} -tag-template: | - ${{ if eq(github.ref_name, 'develop') }}v$NEXT_PATCH_VERSION-beta.${{ env.GITHUB_RUN_NUMBER }}${{ else }}v$NEXT_PATCH_VERSION${{ end }} +name-template: '$RESOLVED_VERSION ๐ŸŒˆ' +tag-template: '$RESOLVED_VERSION' categories: - - title: '๐Ÿš€ New Features' + - title: '๐Ÿš€ Features' labels: - - feature + - 'feature' + - 'enhancement' - title: '๐Ÿ› Bug Fixes' labels: - - bug - - title: '๐Ÿงน Chores' + - 'fix' + - 'bugfix' + - 'bug' + - title: '๐Ÿงฐ Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: labels: - - chore -change-template: '- $TITLE (#$NUMBER)' + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch template: | ## Changes - $CHANGES + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 0abf2c2..0dd90c3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -31,12 +31,7 @@ jobs: - name: Get Release Version id: get_version run: | - VERSION="${{ github.event.release.tag_name }}" - if [[ "${{ github.ref_name }}" == "develop" ]]; then - echo "release_version=${VERSION#v}-beta.${{ env.GITHUB_RUN_NUMBER }}" >> $GITHUB_ENV - else - echo "release_version=${VERSION#v}" >> $GITHUB_ENV - fi + echo "release_version=v${{ github.event.release.tag_name }}" >> $GITHUB_ENV - name: Update Version in Package.json run: | diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..46970d4 --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,88 @@ +name: Release Draft +on: + workflow_dispatch: + workflow_call: + + jobs: + Next_Version: + runs-on: ubuntu-latest + outputs: + next_version: ${{ steps.get_version.outputs.next_version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set Up Git + run: | + git fetch --tags + + - name: Get Current Version Tag + id: get_current_tag + run: | + # Find the latest tag in the current branch (main or develop) + latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1)) + echo "latest_tag=${latest_tag}" >> $GITHUB_ENV + + - name: Determine Next Version + id: get_version + run: | + # Set initial version if no tag found + if [[ -z "$latest_tag" ]]; then + latest_tag="v0.0.0" + fi + + # Extract the version parts + if [[ "$latest_tag" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)(-beta\.[0-9]+)?$ ]]; then + major="${BASH_REMATCH[1]}" + minor="${BASH_REMATCH[2]}" + patch="${BASH_REMATCH[3]}" + beta="${BASH_REMATCH[4]}" + else + echo "Invalid tag format: $latest_tag" + exit 1 + fi + + # Increment the version based on the branch + if [[ "${GITHUB_REF_NAME}" == "main" ]]; then + next_version="v$major.$((minor + 1)).0" # Full release, reset beta + else + if [[ -z "$beta" ]]; then + next_version="v$major.$minor.$patch-beta.1" # Start beta versioning + else + # Increment beta version + beta_number="${beta#*-beta.}" + next_version="v$major.$minor.$patch-beta.$((beta_number + 1))" + fi + fi + + echo "next_version=${next_version}" >> $GITHUB_ENV + echo "::set-output name=next_version::${next_version}" + + Create: + runs-on: ubuntu-latest + needs: Next_Version + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Draft Release (Develop) + if: github.event.pull_request.base.ref == 'develop' + uses: release-drafter/release-drafter@v6 + with: + name: "${{ needs.compute-version.outputs.next_version }}" + tag: "${{ needs.compute-version.outputs.next_version }}" + prerelease: true + commitish: develop + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Draft Release + if: github.event.pull_request.base.ref != 'develop' + uses: release-drafter/release-drafter@v6 + with: + name: "${{ needs.compute-version.outputs.next_version }}" + tag: "${{ needs.compute-version.outputs.next_version }}" + prerelease: false + commitish: main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 50ddaa3..ece3539 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -45,26 +45,6 @@ jobs: package-lock.json ./lib - Release_Drafter: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Draft Release (Develop) - if: github.event.pull_request.base.ref == 'develop' - uses: release-drafter/release-drafter@v6 - with: - prerelease: true - commitish: develop - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Draft Release - if: github.event.pull_request.base.ref != 'develop' - uses: release-drafter/release-drafter@v6 - with: - prerelease: false - commitish: main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + Release_Draft: + needs: Build + uses: ./.github/workflows/release-drafter.yaml \ No newline at end of file