mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-30 08:04:25 +08:00
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
# Please, keep it in sync with `release-django-stubs-ext.yml`
|
|
name: Release django-stubs
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'django-stubs@*'
|
|
|
|
jobs:
|
|
build:
|
|
environment:
|
|
name: django-stubs-pypi
|
|
url: https://pypi.org/project/django-stubs
|
|
|
|
if: github.repository == 'typeddjango/django-stubs'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.9'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install -U pip
|
|
python -m pip install -U setuptools twine wheel
|
|
- name: Build package
|
|
run: |
|
|
python setup.py --version
|
|
python setup.py sdist bdist_wheel
|
|
|
|
- name: Publish package to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
user: __token__
|
|
password: ${{ secrets.DJANGO_STUBS_PYPI_API_TOKEN }}
|
|
packages_dir: './dist'
|
|
print_hash: true
|
|
|
|
- name: Create release
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const tagName = context.ref.replace(/^refs\/tags\//, '');
|
|
const release = await github.rest.repos.createRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag_name: tagName,
|
|
name: `Release ${tagName}`,
|
|
generate_release_notes: true,
|
|
});
|
|
|
|
if (release.status < 200 || release.status >= 300) {
|
|
core.setFailed(`Could not create release for tag '${tagName}'`);
|
|
return;
|
|
}
|
|
|
|
# https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2
|
|
create-issue-on-failure:
|
|
name: Create an issue if release failed
|
|
runs-on: ubuntu-latest
|
|
needs: [build]
|
|
if: ${{ github.repository == 'typeddjango/django-stubs' && always() && needs.build.result == 'failure' }}
|
|
permissions:
|
|
issues: write
|
|
steps:
|
|
- uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
await github.rest.issues.create({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
title: `Release of django-stubs failure on ${new Date().toDateString()}`,
|
|
body: `Details: https://github.com/typeddjango/django-stubs/actions/workflows/release-django-stubs.yml`,
|
|
})
|