-
Notifications
You must be signed in to change notification settings - Fork 13
68 lines (57 loc) · 2.07 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Publish the package on PyPI.
#
# https://pypi.org/project/fabrictestbed-extensions/ is configured
# with GitHub as "trusted publisher", meaning, there is no exchange of
# a long-term password or token between GitHub and PyPI. See
# documentation here: https://docs.pypi.org/trusted-publishers/
name: Publish
# This workflow will be triggered when a tag with prefix "rel" is
# pushed to the repository.
on:
push:
tags:
- "rel*"
jobs:
tests:
uses: ./.github/workflows/test.yml
pypi-publish:
name: Publish packages on PyPI
runs-on: ubuntu-latest
needs:
- tests
environment:
name: publish
url: https://pypi.org/p/fabrictestbed-extensions
# See https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions:
# This permission is mandatory for trusted publishing.
id-token: write
# This permission allows the action to create a release.
contents: write
steps:
- name: Check out sources
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: 'pip'
cache-dependency-path: pyproject.toml
- name: Build package
run: |
python -m pip install --upgrade pip
python -m pip install flit
python -m flit build
# See https://github.com/marketplace/actions/pypi-publish.
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# GitHub CLI (aka "gh" command) is pre-installed in hosted runners.
# See https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows
- name: Create a GitHub release
run: |
RELEASE_TAG=$GITHUB_REF_NAME
RELEASE_TITLE="Release $(echo "$RELEASE_TAG" | sed 's/^rel//g')"
echo "RELEASE_TAG=${RELEASE_TAG}, RELEASE_TITLE=${RELEASE_TITLE}"
gh release create ${RELEASE_TAG} --title="${RELEASE_TITLE}" --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}