From 08297818bf04f587cf7171f41ae0004976f03b52 Mon Sep 17 00:00:00 2001 From: James Socol Date: Sat, 3 Dec 2022 21:02:16 -0500 Subject: [PATCH] Create release action Create an action that uses the pypa/gh-action-pypi-publish reusable action to automate releases. Fixes #267 --- .github/actions/test/action.yml | 28 +++++++++++++++++ .github/workflows/ci.yml | 15 ++------- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 .github/actions/test/action.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 0000000..73d6392 --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,28 @@ +name: test +description: 'runs a test matrix' +inputs: + python-version: + required: true + django-version: + required: true + +runs: + using: "composite" + steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ inputs.python-version }} + + - name: Install dependencies + shell: sh + run: | + python -m pip install --upgrade pip + if [[ ${{ inputs.django-version }} != 'main' ]]; then pip install --pre -q "Django>=${{ inputs.django-version }},<${{ inputs.django-version }}.99"; fi + if [[ ${{ inputs.django-version }} == 'main' ]]; then pip install https://github.com/django/django/archive/main.tar.gz; fi + pip install flake8 django-redis pymemcache + + - name: Test + shell: sh + run: | + ./run.sh test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa24b57..b4b4142 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,21 +28,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - uses: ./.github/actions/test with: python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [[ ${{ matrix.django }} != 'main' ]]; then pip install --pre -q "Django>=${{ matrix.django }},<${{ matrix.django }}.99"; fi - if [[ ${{ matrix.django }} == 'main' ]]; then pip install https://github.com/django/django/archive/main.tar.gz; fi - pip install flake8 django-redis pymemcache - - - name: Test - run: | - ./run.sh test + django-version: ${{ matrix.django }} lint: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d07b84e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: release + +on: + push: + tags: + - v* + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + django: ['3.2', '4.0', '4.1'] + exclude: + - python-version: '3.7' + django: '4.0' + - python-version: '3.7' + django: '4.1' + + 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] + steps: + + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v2 + 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 + with: + password: ${{ secrets.PYPI_DEPLOY_TOKEN }}