Skip to content

Create release

Create release #15

name: Create a release
on:
workflow_dispatch:
jobs:
build:
name: Create a release tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ vars.CI_PYTHON_VERSION }}
- uses: snok/install-poetry@v1
with:
version: ${{ vars.CI_POETRY_VERSION }}
- name: Generate tag
id: version-tag
run: echo "CALVER=$(date +%y.%m.%d).${{ github.run_number }}" >> "$GITHUB_OUTPUT"
- name: Update version and push
run: |
git checkout -b "release/v${{ steps.version-tag.outputs.CALVER }}"
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
poetry version "${{ steps.version-tag.outputs.CALVER }}"
git add pyproject.toml
git commit -m "Release ${{ steps.version-tag.outputs.CALVER }}"
git push --set-upstream origin "release/v${{ steps.version-tag.outputs.CALVER }}"
git tag v${{ steps.version-tag.outputs.CALVER }} -m "Version ${{ steps.version-tag.outputs.CALVER }}"
git push origin --tags
- name: Create pull request
run: gh pr create -B main -H "release/v${{ steps.version-tag.outputs.CALVER }}" --title "Version ${{ steps.version-tag.outputs.CALVER }}" --body "Created by Github action https://github.com/nationalarchives/ds-wagtail/actions/runs/${{ github.run_id }}" --no-maintainer-edit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Merge the pull request
run: gh pr merge "release/v${{ steps.version-tag.outputs.CALVER }}" --auto --admin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
run: gh release create "v${{ steps.version-tag.outputs.CALVER }}" --title "${{ steps.version-tag.outputs.CALVER }}" --draft --generate-notes --latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}