-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (85 loc) · 2.55 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This workflow will build a Python project using sdist bdist_wheel
# and publish to PyPI.
name: Publish
on:
push:
tags:
- 'v*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
ARTIFACT_NAME: sphinx_emoji_favicon_dist
ARTIFACT_DIR: dist
# OS_NAME_VERSION: ubuntu-latest
jobs:
build:
# Don't run on forked repos.
if: github.repository_owner == 'DeepPSP'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel build
pip install -r requirements.txt
- name: Install Hatch
uses: pypa/hatch@install
- name: List installed Python packages
run: |
python -m pip list
- name: Build
run: |
python -m build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: dist
github-release:
# github release and changelog
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.changelog }}
pypi-publish:
# publishing is separated from building
needs: build
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}
- name: Publish package to TestPyPI # to test, use https://test.pypi.org/
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: ${{ env.ARTIFACT_DIR }}
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: ${{ env.ARTIFACT_DIR }}