| 1 | name: Draft a release |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | version: |
| 7 | description: 'The version number (e.g. 1.2.3) OR one of: patch|minor|major|prepatch|preminor|premajor|prerelease' |
| 8 | required: true |
| 9 | default: 'patch' |
| 10 | |
| 11 | jobs: |
| 12 | draft-release: |
| 13 | runs-on: ubuntu-latest |
| 14 | steps: |
| 15 | - uses: actions/checkout@v5 |
| 16 | - uses: ./.github/actions/python-poetry-env |
| 17 | - name: Update version |
| 18 | id: updated_version |
| 19 | shell: bash |
| 20 | run: | |
| 21 | poetry version ${{ github.event.inputs.version }} |
| 22 | version=$(poetry version --short) |
| 23 | echo ::set-output name="version::$version" |
| 24 | - name: Update changelog |
| 25 | id: changelog |
| 26 | shell: bash |
| 27 | run: | |
| 28 | poetry run kacl-cli release ${{ steps.updated_version.outputs.version }} --modify --auto-link |
| 29 | echo "" >> CHANGELOG.md |
| 30 | body=$(poetry run kacl-cli get ${{ steps.updated_version.outputs.version }}) |
| 31 | body="${body//'%'/'%25'}" |
| 32 | body="${body//$'\n'/'%0A'}" |
| 33 | body="${body//$'\r'/'%0D'}" |
| 34 | echo ::set-output name="body::$body" |
| 35 | - name: Commit changes |
| 36 | uses: EndBug/add-and-commit@v9 |
| 37 | with: |
| 38 | add: 'CHANGELOG.md pyproject.toml' |
| 39 | message: 'Release ${{ steps.updated_version.outputs.version }}' |
| 40 | default_author: github_actions |
| 41 | - name: Create tag |
| 42 | run: | |
| 43 | git tag ${{ steps.updated_version.outputs.version }} |
| 44 | git push origin ${{ steps.updated_version.outputs.version }} |
| 45 | - name: Create a draft release |
| 46 | uses: actions/create-release@v1 |
| 47 | env: |
| 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | with: |
| 50 | tag_name: ${{ steps.updated_version.outputs.version }} |
| 51 | release_name: Release ${{ steps.updated_version.outputs.version }} |
| 52 | body: ${{ steps.changelog.outputs.body }} |
| 53 | draft: true |