-
Notifications
You must be signed in to change notification settings - Fork 16
143 lines (130 loc) · 4.34 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: release
on:
workflow_dispatch:
jobs:
build:
name: Build with semantic versioning
runs-on: ubuntu-latest
outputs:
release-tag: ${{ steps.release.outputs.tag }}
release-version: ${{ steps.release.outputs.version }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Python Semantic Release
id: release
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check release
if: steps.release.outputs.released == 'false'
run: |
echo 'No release will be made since there are no release commits. See also Commit Parsers configuration.'
exit 1
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install build tools
run: |
make install-dev
- name: Build
run: |
make build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
publish-to-github:
name: Publish to GitHub
needs:
- build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: |
./dist/*.tar.gz
./dist/*.whl
- name: Upload package distributions to GitHub Releases
run: gh release upload ${{needs.build.outputs.release-tag}} ./dist/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.REPOSITORY }}
publish-to-testpypi:
name: Publish to TestPyPI
needs:
- build
- publish-to-github
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://pypi.org/p/compliance-to-policy
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download the distributions from release
run: gh release download ${{needs.build.outputs.release-tag}} -D dist -p '*.tar.gz' -p '*.whl'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.REPOSITORY }}
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
test:
name: Integration Test
needs:
- build
- publish-to-testpypi
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{needs.build.outputs.release-tag}}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install
run: |
version=${{needs.build.outputs.release-version}}
version=${version/-rc./rc}
count=0
while :; do
count=$(($count+1))
echo "Check if ${version} is available or not ...$count"
if pip index versions -i https://test.pypi.org/simple/ compliance-to-policy | grep ${version};then
break
fi
[[ "$count" -gt 5 ]] && echo "Not found ${version}" && exit 1
sleep 5
done
pip index versions -i https://test.pypi.org/simple/ compliance-to-policy | grep ${version}
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple compliance-to-policy==${version}
pip install pytest
- name: Run test
run: make it