Skip to content

Commit

Permalink
Merge pull request #72 from jsocol/automate-releases
Browse files Browse the repository at this point in the history
Automate releases
  • Loading branch information
jsocol authored Dec 5, 2023
2 parents bdc9299 + bc79fcb commit 506b98f
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:

- name: Lint with flake8
run: |
./run.sh check
./run.sh lint
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: release

on:
push:
tags:
- v*

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.10', '3.11']
django: ['3.2', '4.2', '5.0']
include:
- python-version: '3.12'
django: '5.0'

steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/test
with:
python-version: ${{ matrix.python-version }}
django-version: ${{ matrix.django }}

release:
runs-on: ubuntu-latest
needs: [test]
environment: release
permissions:
id-token: write
steps:

- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: build
run: ./run.sh build

- name: check
run: ./run.sh check

- name: release
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions adminplus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def always_hidden(request):
return 'i am here, but not shown'
site.register_view('always-hidden', view=always_visible, visible=False)

cond = lambda req: req.user.pk == 1
b = lambda s: s.encode('ascii') if hasattr(s, 'encode') else s
cond = lambda req: req.user.pk == 1 # noqa: E731
b = lambda s: s.encode('ascii') if hasattr(s, 'encode') else s # noqa: #731

@site.register_view(r'conditional-view', visible=cond)
class ConditionallyVisible(View):
Expand Down
35 changes: 27 additions & 8 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,40 @@
export PYTHONPATH=".:$PYTHONPATH"
export DJANGO_SETTINGS_MODULE="test_settings"

PROG="$0"
CMD="$1"
shift

usage() {
echo "USAGE: $0 [command]"
echo "USAGE: $PROG [command]"
echo " test - run the adminplus tests"
echo " check - run flake8 checks"
echo " lint - run flake8 (alias: flake8)"
echo " shell - open the Django shell"
echo " build - build a package for release"
echo " check - run twine check on build artifacts"
exit 1
}

case "$1" in
case "$CMD" in
"test" )
django-admin test adminplus ;;
"check" )
flake8 adminplus/ --exclude=tests*.py ;;
echo "Django version: $(python -m django --version)"
python -m django test adminplus
;;
"lint"|"flake8" )
echo "Flake8 version: $(flake8 --version)"
flake8 "$@" adminplus/
;;
"shell" )
django-admin shell ;;
python -m django shell
;;
"build" )
rm -rf dist/*
python -m build
;;
"check" )
twine check dist/*
;;
* )
usage ;;
usage
;;
esac

0 comments on commit 506b98f

Please sign in to comment.