diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..1c9f2e3 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,17 @@ +name-template: 'Draft' +template: | + # What's Changed + + $CHANGES + +categories: + - title: '🚀 Features' + label: 'enhancement' + - title: '🐛 Bug Fixes' + label: 'bug' + - title: '📝 Documentation' + label: 'documentation' + collapse-after: 5 + +exclude-labels: + - 'skip-changelog' diff --git a/.github/workflows/continuous_delivery.yml b/.github/workflows/continuous_delivery.yml index fd783f7..2808109 100644 --- a/.github/workflows/continuous_delivery.yml +++ b/.github/workflows/continuous_delivery.yml @@ -39,12 +39,12 @@ jobs: - name: Extract version from pyproject.toml id: extract_version run: | - VERSION=$(poetry version -s) + VERSION=v$(poetry version -s) echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV - name: Verify if version has changed id: version_check run: | - if [ $(git tag -l "v${{ env.PACKAGE_VERSION }}") ]; then + if [ $(git tag -l ${{ env.PACKAGE_VERSION }}") ]; then echo "Version ${{ env.PACKAGE_VERSION }} already exists." exit 0 fi @@ -58,5 +58,32 @@ jobs: run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "GitHub Actions" - git tag "v${{ env.PACKAGE_VERSION }}" - git push origin "v${{ env.PACKAGE_VERSION }}" + git tag "${{ env.PACKAGE_VERSION }}" + git push origin "${{ env.PACKAGE_VERSION }}" + - name: Publish Draft Release + if: ${{ success() && matrix.python-version == 3.8 }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: releases } = await github.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + + const draftRelease = releases.find(r => r.draft && r.name === 'Draft'); + + if (draftRelease) { + await github.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: draftRelease.id, + tag_name: process.env.PACKAGE_VERSION, + name: process.env.PACKAGE_VERSION, + draft: false + }); + } else { + core.setFailed(`Draft release named "Draft" not found.`); + }; + env: + PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} diff --git a/.github/workflows/pull_request_style_check.yml b/.github/workflows/pull_request_style_check.yml new file mode 100644 index 0000000..2649d4a --- /dev/null +++ b/.github/workflows/pull_request_style_check.yml @@ -0,0 +1,24 @@ +name: Pull Request Style Check + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - labeled + - unlabeled + - edited + branches: + - develop + + +jobs: + check_cc_labels: + name: check conventional commits labels + runs-on: ubuntu-latest + steps: + - uses: danielchabr/pr-labels-checker@v3.3 + with: + hasSome: bug, documentation, enhancement + githubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release_draft.yml b/.github/workflows/release_draft.yml new file mode 100644 index 0000000..cadfae7 --- /dev/null +++ b/.github/workflows/release_draft.yml @@ -0,0 +1,19 @@ +name: Release Draft + +on: + push: + branches: + - develop + +jobs: + draft_release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Draft a new release + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}