Automate releases
josegonzalez opened this issue · 5 comments
If someone wants to automate releases, that would be swell. Basically just write the github actions script that runs ./release $SEMVER_BUMP
, where $SEMVER_BUMP
is patch
, minor
, or major
. The action should install release-requirements.txt
. I use twine
for releases, so it should probably also have a way to authenticate to pypi.
Why this? That way I can move this and python-gitlab-backup
to an org, grant folks access to it, and then let others who are interested in actively maintaining the project do so.
I am fairly new to using GitHub Actions, but I'd like to experiment and work on this if possible.
What particular event (on
) should trigger the running of the script, as you describe?
I use a workflow_dispatch
for dokku: https://github.com/dokku/dokku/blob/master/.github/workflows/release.yml
I've currently got the following:
name: automatic-release
on:
workflow_dispatch:
inputs:
release_type:
description: Release type
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
name: Release
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install prerequisites
run: pip install -r release-requirements.txt
- name: Execute release
env:
SEMVER_BUMP: ${{ github.event.inputs.release_type }}
TWINE_REPOSITORY: ${{ vars.TWINE_REPOSITORY }}
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: ./release $SEMVER_BUMP
This has a dropdown manual workflow trigger for "patch", "minor" and "major". It has a e.g. repo specified environment variable TWINE_REPOSITORY
for pypi
or testpypi
(production or test). It has two e.g. repo secrets TWINE_USERNAME
and TWINE_PASSWORD
for pypi authentication.
I have successfully (after multiple failed attempts) ran this with on a slightly modified fork to get a test release and a error free workflow: https://test.pypi.org/project/ondkloss-github-backup/#description
The run: https://github.com/Ondkloss/python-github-backup/actions/runs/6535505694/job/17745125180
Issues and comments so far:
- Currently unsure/untested if I need to
setup-python
- It generates faulty(?) changelog. See e.g. the resulting
CHANGES.rst
from my testpypi release, which pretty much overwrote everything: https://github.com/Ondkloss/python-github-backup/blob/master/CHANGES.rst
I can't really say I'm understanding how this happens from thegitchangelog
call - I see a
docs/conf.py
section inrelease
that I don't know what is and if I have to handle it somehow - There's no particular thought to the choice of Ubuntu 20.04
- Pypi warns that username/password will require 2FA soon. Unsure how to handle another form of authentication using twine
Mind making the PR to start and we can work through issues there?
This works great! Thanks for implementing it :)