-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ferdinand Hoffmann
committed
Jun 10, 2021
1 parent
c786367
commit aee00d2
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' | ||
|
||
name: Create release and attach sdist | ||
|
||
jobs: | ||
build: | ||
name: Build sdist and create release draft | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install build | ||
- name: Build sdist | ||
run: | | ||
python -m build --sdist | ||
- name: Get version from tag | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} | ||
- name: Check package version (compare package version with tag) | ||
id: check_package_version | ||
shell: python | ||
run: | | ||
from packaging.version import parse | ||
from setuptools.config import read_configuration | ||
package_version = read_configuration('setup.cfg')['metadata']['version'] | ||
if parse(package_version) != parse('${{ steps.get_version.outputs.VERSION }}'): | ||
print(f'version mismatch: {package_version} (package) vs ${{ steps.get_version.outputs.VERSION }} (tag)') | ||
exit(1) | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: true | ||
prerelease: false | ||
- name: Upload Release Asset | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: ./dist/django-questionnaire-core-${{ steps.get_version.outputs.VERSION }}.tar.gz | ||
asset_name: django-questionnaire-core-${{ steps.get_version.outputs.VERSION }}.tar.gz | ||
asset_content_type: application/tar+gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
release: | ||
types: [published] | ||
|
||
name: Upload release to PyPI | ||
jobs: | ||
generate: | ||
name: Create release-artifacts | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
- name: Install build dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Build sdist & wheel | ||
run: | | ||
python -m build --sdist --wheel | ||
- name: Publish a Python distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
# repository_url: https://test.pypi.org/legacy/ |