-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
51b8e82
commit f627931
Showing
1 changed file
with
70 additions
and
21 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 |
---|---|---|
@@ -1,31 +1,80 @@ | ||
name: Python package | ||
on: | ||
push: | ||
tags: | ||
- "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10 | ||
|
||
on: [push] | ||
name: Create and Publish Release | ||
|
||
jobs: | ||
build: | ||
|
||
name: Build distribution | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install release dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade setuptools wheel build | ||
- uses: snok/install-poetry@v1 | ||
- name: Get release notes | ||
id: release_notes | ||
run: | | ||
# By default, GH Actions checkout will only fetch a single commit. | ||
# For us to extract the release notes, we need to fetch the tags | ||
# and tag annotations as well. | ||
# https://github.com/actions/checkout/issues/290 | ||
git fetch --tags --force | ||
TAG_NAME=${GITHUB_REF/refs\/tags\//} | ||
echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md" | ||
- uses: actions/cache@v2 | ||
with: | ||
path: .venv | ||
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} | ||
- name: Create GitHub release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
body_path: "${{ runner.temp }}/CHANGELOG.md" | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Test code | ||
run: poetry run pytest | ||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/babelfont | ||
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 PyPI | ||
uses: pypa/gh-action-pypi-publish@v1.8.14 | ||
with: | ||
# repository-url: https://test.pypi.org/legacy/ # for testing purposes | ||
verify-metadata: false # twine previously didn't verify metadata when uploading |