forked from probabl-ai/skore
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (115 loc) · 4.5 KB
/
release.yml
File metadata and controls
132 lines (115 loc) · 4.5 KB
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
# Release a package.
#
# This workflow is triggered by a "release" or "pre-release" event.
# Being in a mono-repository with multiple packages, if the corresponding tag is not
# prefixed by the name of the package, it fails.
#
# Example of valid tags: `skore/1.0.0-rc.1` or `skore/1.0.0`.
name: release
on:
release:
types: [released, prereleased]
env:
UUID: ${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
permissions: {}
jobs:
tag-decomposition:
name: Decompose tag to retrieve package and version
runs-on: ubuntu-latest
outputs:
package: ${{ steps.tag-decomposition.outputs.package }}
version: ${{ steps.tag-decomposition.outputs.version }}
steps:
- shell: bash
id: tag-decomposition
run: |
package="${GITHUB_REF_NAME%/*}"
version="${GITHUB_REF_NAME#*/}"
[[ "${package}" == "${version}" ]] && { >&2 echo "Invalid tag: no package"; exit 1; }
[[ "${package}" =~ ^(skore|skore-(local|hub)-project)$ ]] || { >&2 echo "Invalid tag: invalid package"; exit 1; }
[[ "${version}" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-rc\.(1|[1-9][0-9]*))?$ ]] || { >&2 echo "Invalid tag: invalid version"; exit 1; }
echo "::group::Details"
echo "package=${package}" | tee --append "${GITHUB_OUTPUT}"
echo "version=${version}" | tee --append "${GITHUB_OUTPUT}"
echo "::endgroup::"
build:
name: Build package distributions
runs-on: ubuntu-latest
permissions:
contents: read
needs: [tag-decomposition]
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Override VERSION.txt with tag
working-directory: ${{ needs.tag-decomposition.outputs.package }}
run: echo "${VERSION}" > VERSION.txt
env:
VERSION: ${{ needs.tag-decomposition.outputs.version }}
- name: Set up Python 3.12
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: "3.12"
- name: Build package distributions
working-directory: ${{ needs.tag-decomposition.outputs.package }}
run: python -m pip install build && python -m build
- name: Checks whether distribution’s long description will render correctly on PyPI
working-directory: ${{ needs.tag-decomposition.outputs.package }}
continue-on-error: true
run: |
python -m pip install twine
python -m twine check dist/*
- name: Upload package distributions
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: ${{ env.UUID }}
path: ${{ needs.tag-decomposition.outputs.package }}/dist/
publish:
name: Publish package distributions to PyPI using trusted publisher
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
needs: [tag-decomposition, build]
steps:
- name: Download package distributions
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: ${{ env.UUID }}
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
verify-metadata: false
communicate:
name: Communicate on slack about the new release
runs-on: ubuntu-latest
needs: [tag-decomposition, publish]
continue-on-error: true
steps:
- name: Post to slack
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: "product-releases"
text: ${{ github.event.release.html_url }}
blocks:
- type: "section"
text:
type: "mrkdwn"
text: ${{ toJSON(github.event.release.html_url) }}
- type: "section"
text:
type: "mrkdwn"
text: ${{ toJSON(format('>>> {0}', github.event.release.body)) }}
clean:
name: Delete package distributions artifacts
runs-on: ubuntu-latest
if: always()
needs: [tag-decomposition, publish]
steps:
- uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
with:
name: ${{ env.UUID }}