diff --git a/.github/git-pr-release-template.erb b/.github/git-pr-release-template.erb new file mode 100644 index 0000000..a47b522 --- /dev/null +++ b/.github/git-pr-release-template.erb @@ -0,0 +1,3 @@ +<%= ENV['GIT_PR_RELEASE_TITLE'] %> + +<%= ENV['GIT_PR_RELEASE_BODY'] %> diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..d530f4d --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,69 @@ +prerelease: true + +# Filter previous releases considering target_commitish +include-pre-releases: true +filter-by-commitish: true + +# Versioning configuration +tag: "v0.0.0" + +categories: + - title: 'BREAKING CHANGES' + labels: + - 'breaking' + - title: '๐Ÿ’Ž Features' + labels: + - 'feature' + - title: '๐Ÿš€ Improvement' + labels: + - 'enhancement' + - title: '๐Ÿ› Bug Fixes' + labels: + - 'bug' + - title: '๐Ÿงฐ Maintenance' + labels: + - 'support' + - 'dependencies' + - title: '๐Ÿงน Chore' + labels: + - 'chore' + +category-template: '### $TITLE' + +change-title-escapes: '\<*_&#@`' # Updated to disable mentions and code blocks + +autolabeler: + - label: 'feature' + branch: + - '/^feat\/.+/' + - label: 'enhancement' + branch: + - '/^refac\/.+/' + - label: 'bug' + branch: + - '/^fix\/.+/' + title: + - '/^fix/i' + - label: 'support' + branch: + - '/^support\/.+/' + title: + - '/^support/i' + - '/^chore/i' + - '/^ci/i' + - '/^docs/i' + - '/^test/i' + +include-labels: + - breaking + - feature + - enhancement + - bug + - support + - dependencies + +exclude-labels: + - 'exclude-from-changelog' + +template: | + $CHANGES diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 0000000..9f7b6ea --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,50 @@ +name: Draft Release + +on: + push: + branches: + - main + - dev/*.*.* + +permissions: + contents: write + actions: write # Necessary to cancel workflow executions + checks: write # Necessary to write reports + pull-requests: write # Necessary to comment on PRs + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + # Refs: https://github.com/release-drafter/release-drafter + update-release-draft: + runs-on: ubuntu-latest + + outputs: + CURRENT_VERSION: ${{ steps.version.outputs.project_version }} + RELEASE_DRAFT_BODY: ${{ steps.release-drafter.outputs.body }} + + steps: + - uses: actions/checkout@v4 + with: + repository: ut-issl/c2a-generator + ssh-key: ${{ secrets.PRIVATE_REPO_SSH_KEY }} + + - name: Read version from pyproject.toml + id: version + run: | + version=$(awk -F\" '/version =/ {print $2}' pyproject.toml) + echo "::set-output name=project_version::$version" + + - uses: release-drafter/release-drafter@v6 + id: release-drafter + with: + config-name: release-drafter.yml + name: v${{ steps.version.outputs.project_version }} + tag: v${{ steps.version.outputs.project_version }} + version: ${{ steps.version.outputs.project_version }} + disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..aa1056c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Release + +on: + pull_request: + branches: + - main + types: [closed] + +permissions: + contents: write + +jobs: + create-github-release: + + runs-on: ubuntu-latest + + if: github.event.pull_request.merged == true + + outputs: + RELEASED_VERSION: ${{ steps.version.outputs.project_version }} + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.base.ref }} + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install dependencies + run: | + yarn global add turbo + yarn global add node-gyp + yarn --frozen-lockfile + + - name: Read version from VERSION file + id: version + run: echo "::set-output name=project_version::$(cat VERSION)" + + - name: Read version from pyproject.toml + id: version + run: | + version=$(awk -F\" '/version =/ {print $2}' pyproject.toml) + echo "::set-output name=project_version::$version" + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: v${{ steps.version.outputs.project_version }} + release-notes: ${{ github.event.pull_request.body }} + + - name: Commit, Tag and Push + uses: stefanzweifel/git-auto-commit-action@v5 + with: + branch: ${{ github.event.pull_request.base.ref }} + commit_message: Release v${{ steps.version.outputs.project_version }} + tagging_message: v${{ steps.version.outputs.project_version }} + + - uses: softprops/action-gh-release@v2 + with: + body: ${{ github.event.pull_request.body }} + tag_name: v${{ steps.version.outputs.project_version }} + target_commitish: ${{ github.head_ref }} + + - name: Delete drafts + uses: hugo19941994/delete-draft-releases@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}