-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (111 loc) · 3.99 KB
/
release.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Release and publish 📦
# detect new version and create tag for it, build Python 📦
# generate release notes for GitHub release
# If tag for new version was created, then publish GitHub release
# publish Python 📦 to PyPI (if tag exists) and 🧪TestPyPI (if it was a merged PR)
env:
# Specify Python version to quick change in the future
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
PYTHON_VERSION: "3.11"
on:
push:
branches:
- main
- master
jobs:
build-package-and-publish-gh-release:
name: Release
runs-on: ubuntu-latest
outputs:
new-version-tag: ${{ steps.check-version.outputs.tag }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
- name: Bump version for developmental release
if: steps.check-version.outputs.tag == ''
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%Y%m%d%H%M%S)
- name: Build a binary wheel (.whl) and a source tarball (.tr.gz)
run: |
poetry build --ansi
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish the release notes
uses: release-drafter/release-drafter@master
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
name: ${{ steps.check-version.outputs.tag }} of Playlist Along
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-to-pypi:
name: >-
📦 to PyPI | Publish Python 🐍 distribution
if: needs.build-package-and-publish-gh-release.outputs.new-version-tag != ''
needs:
- build-package-and-publish-gh-release
runs-on: ubuntu-latest
environment:
name: 'PyPI'
url: https://pypi.org/p/playlist-along
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all built files
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-to-test-pypi:
name: 📦 to 🧪TestPyPI | Publish Python 🐍 distribution
if: needs.build-package-and-publish-gh-release.outputs.new-version-tag == ''
needs:
- build-package-and-publish-gh-release
runs-on: ubuntu-latest
environment:
name: 'Test PyPI'
url: https://test.pypi.org/p/playlist-along
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all built file
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish 📦 to 🧪TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/