mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-09-20 03:02:34 +03:00
Split test release workflow from actual
This commit is contained in:
parent
a9cc1cc052
commit
2a8ec136c3
41
.github/workflows/release.yml
vendored
41
.github/workflows/release.yml
vendored
|
@ -1,10 +1,18 @@
|
||||||
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
|
name: Publish Python 🐍 distribution 📦 to PyPI
|
||||||
|
|
||||||
on: push
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
# Order matters, the last rule that applies to a tag
|
||||||
|
# is the one that takes effect:
|
||||||
|
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches-and-tags
|
||||||
|
- '*'
|
||||||
|
# There should be no dev tags created, but to be safe,
|
||||||
|
# let's not publish them.
|
||||||
|
- '!*.dev*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYPI_URL: https://pypi.org/p/djangorestframework
|
PYPI_URL: https://pypi.org/p/djangorestframework
|
||||||
PYPI_TEST_URL: https://test.pypi.org/p/djangorestframework
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
@ -32,7 +40,6 @@ jobs:
|
||||||
publish-to-pypi:
|
publish-to-pypi:
|
||||||
name: >-
|
name: >-
|
||||||
Publish Python 🐍 distribution 📦 to PyPI
|
Publish Python 🐍 distribution 📦 to PyPI
|
||||||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
|
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -92,29 +99,3 @@ jobs:
|
||||||
gh release upload
|
gh release upload
|
||||||
'${{ github.ref_name }}' dist/**
|
'${{ github.ref_name }}' dist/**
|
||||||
--repo '${{ github.repository }}'
|
--repo '${{ github.repository }}'
|
||||||
|
|
||||||
publish-to-testpypi:
|
|
||||||
name: Publish Python 🐍 distribution 📦 to TestPyPI
|
|
||||||
if: startsWith(github.ref, 'refs/tags/') # only publish to Test PyPI on tag pushes
|
|
||||||
needs:
|
|
||||||
- build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
environment:
|
|
||||||
name: testpypi
|
|
||||||
url: ${{ env.PYPI_TEST_URL }}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Download all the dists
|
|
||||||
uses: actions/download-artifact@v5
|
|
||||||
with:
|
|
||||||
name: python-package-distributions
|
|
||||||
path: dist/
|
|
||||||
- name: Publish distribution 📦 to TestPyPI
|
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1.13
|
|
||||||
with:
|
|
||||||
repository-url: https://test.pypi.org/legacy/
|
|
||||||
skip-existing: true
|
|
||||||
|
|
103
.github/workflows/test_release.yml
vendored
Normal file
103
.github/workflows/test_release.yml
vendored
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
name: Test Python 🐍 distribution 📦 to TestPyPI
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
iteration:
|
||||||
|
description: 'A unique iteration for the run. The tag will be suffixed with .devyyyymmdd<iteration>'
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
default: "0"
|
||||||
|
schedule:
|
||||||
|
# Run the second day of every month.
|
||||||
|
- cron: "12 3 2 * *"
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYPI_TEST_URL: https://test.pypi.org/p/djangorestframework
|
||||||
|
# The environment key that overrides the version number
|
||||||
|
DEV_VERSION_ENV_KEY: BEST_PRACTICES_VERSION_DEV
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-dev-version:
|
||||||
|
# Generate the dev version suffix based on the current date.
|
||||||
|
# Tag name:
|
||||||
|
# <version>.dev<yyyymmdd><iteration>
|
||||||
|
name: Create dev version string
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
dev_version: ${{ steps.output-dev-version.outputs.dev_version }}
|
||||||
|
steps:
|
||||||
|
- name: Set date suffix
|
||||||
|
id: set-date
|
||||||
|
run: echo "suffix=dev$(date +%Y%m%d)" >> $GITHUB_ENV
|
||||||
|
- name: Determine Iteration Value
|
||||||
|
id: set-iteration
|
||||||
|
# If the action is running on a schedule, default iteration to 0
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
||||||
|
echo "iteration=${{ github.event.inputs.iteration }}" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "iteration=0" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
- name: Output dev version
|
||||||
|
id: output-dev-version
|
||||||
|
# Don't output a dev version if the push was for a tag.
|
||||||
|
run: |
|
||||||
|
if [[ "${{ startsWith(github.ref, 'refs/tags') }}" == "true" ]]; then
|
||||||
|
echo "dev_version=" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "dev_version=${{ env.suffix }}${{ env.iteration }}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build distribution 📦
|
||||||
|
needs:
|
||||||
|
- create-dev-version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.x"
|
||||||
|
- name: Install pypa/build
|
||||||
|
run:
|
||||||
|
python3 -m pip install build --user
|
||||||
|
- name: Build a binary wheel and a source tarball
|
||||||
|
env:
|
||||||
|
DEV_VERSION: ${{needs.create-dev-version.outputs.dev_version}}
|
||||||
|
run: ${{ env.DEV_VERSION_ENV_KEY }}="${{ env.DEV_VERSION }}" python3 -m build
|
||||||
|
- name: Store the distribution packages
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: python-package-distributions
|
||||||
|
path: dist/
|
||||||
|
|
||||||
|
publish-to-testpypi:
|
||||||
|
name: Publish Python 🐍 distribution 📦 to TestPyPI
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
environment:
|
||||||
|
name: testpypi
|
||||||
|
url: ${{ env.PYPI_TEST_URL }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write # IMPORTANT: mandatory for trusted publishing
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download all the dists
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: python-package-distributions
|
||||||
|
path: dist/
|
||||||
|
- name: Publish distribution 📦 to TestPyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1.12
|
||||||
|
with:
|
||||||
|
repository-url: https://test.pypi.org/legacy/
|
||||||
|
skip-existing: true
|
Loading…
Reference in New Issue
Block a user