-
Notifications
You must be signed in to change notification settings - Fork 4
206 lines (171 loc) · 6.6 KB
/
build_publish_compute.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Publish compute pypi package and create a release
on:
workflow_dispatch:
inputs:
bump:
description: "Bump the version of the compute"
type: choice
required: true
default: "patch"
options:
- "patch"
- "minor"
- "major"
- "prepatch"
- "preminor"
- "premajor"
env:
PRERELEASE: ${{ contains(inputs.bump, 'pre') }}
jobs:
python_project:
name: Build ecoindex compute python project
runs-on: ubuntu-latest
outputs:
wheel: ${{ steps.wheel.outputs.wheel }}
compute_version: ${{ steps.version.outputs.compute_version }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Install poetry build project
run: pip install poetry-multiproject-plugin
- name: Bump version
run: task compute:bump -- ${{ github.event.inputs.bump }}
- name: Build
run: task compute:poetry:build
- name: Upload version to artifacts
uses: actions/upload-artifact@v4
with:
name: version
path: components/ecoindex/compute/VERSION
- name: Upload pyproject.toml to artifacts
uses: actions/upload-artifact@v4
with:
name: pyproject
path: projects/ecoindex_compute/pyproject.toml
- name: Upload dist folder
uses: actions/upload-artifact@v4
with:
name: dist
path: projects/ecoindex_compute/dist
- name: Output version
id: version
run: echo "compute_version=$(task compute:poetry:version-short)" >> $GITHUB_OUTPUT
- name: Output wheel
id: wheel
run: echo "wheel=ecoindex_compute-${{ steps.version.outputs.compute_version }}-py3-none-any.whl" >> $GITHUB_OUTPUT
- name: Output summary
run: |
echo "Compute version ${{ steps.version.outputs.compute_version }}" >> $GITHUB_STEP_SUMMARY
echo "Wheel ${{ steps.wheel.outputs.wheel }}" >> $GITHUB_STEP_SUMMARY
pypi_package:
name: Build and push compute pypi package
runs-on: ubuntu-latest
needs: python_project
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
- name: Download dist from artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: projects/ecoindex_compute/dist
- name: Download pyproject.toml from artifacts
uses: actions/download-artifact@v4
with:
name: pyproject
path: /tmp
- name: Copy pyproject.toml to the project
run: cp /tmp/pyproject.toml projects/ecoindex_compute/pyproject.toml
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Login to Pypi
run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
# - name: Publish
# run: task compute:pypi:publish
release:
name: Create a release
runs-on: ubuntu-latest
needs: [python_project, pypi_package]
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Git pull
run: git pull
- name: Download pyproject.toml to a temporary file
uses: actions/download-artifact@v4
with:
name: pyproject
path: /tmp
- name: Download VERSION to a temporary file
uses: actions/download-artifact@v4
with:
name: version
path: /tmp
- name: Copy and overwrite existing files to the repo
run: |
cp /tmp/pyproject.toml projects/ecoindex_compute/pyproject.toml
cp /tmp/VERSION components/ecoindex/compute/VERSION
- uses: oprypin/find-latest-tag@v1
id: last_tag
with:
repository: ${{ github.repository }}
releases-only: false
regex: '^v[0-9]+\.[0-9]+\.[0-9]+@compute$'
- name: Commit files
uses: EndBug/add-and-commit@v9
with:
message: "chore(compute): Bump compute version to ${{ needs.python_project.outputs.compute_version }}"
tag: v${{ needs.python_project.outputs.compute_version }}@compute
tag_push: "--force"
push: true
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: v${{ needs.python_project.outputs.compute_version }}@compute
toTag: ${{ steps.last_tag.outputs.tag }}
excludeScopes: api,cli,scraper
changelogFilePath: /tmp/changelog.md
- name: Update changelog content with dockerhub links
run: |
echo -e "${{ steps.changelog.outputs.changes }}\n\n" > /tmp/changelog.md
echo -e "### Pypi package\n\n" >> /tmp/changelog.md
echo "Pypi package have been built and pushed to Pypi: [ecoindex-compute:${{ needs.python_project.outputs.compute_version }}](https://pypi.org/project/ecoindex-compute/${{ needs.python_project.outputs.compute_version }}/)" >> /tmp/changelog.md
- name: Create Release
uses: ncipollo/release-action@v1
id: create_release
with:
allowUpdates: true
prerelease: ${{ env.PRERELEASE }}
makeLatest: true
name: "Compute: v${{ needs.python_project.outputs.compute_version }}"
tag: v${{ needs.python_project.outputs.compute_version }}@compute
token: ${{ github.token }}
bodyFile: /tmp/changelog.md
- name: Create Mattermost file
run: |
echo -e "{\"icon_url\":\"https://icon-library.com/images/github-icon-png/github-icon-png-29.jpg\",\"text\":\"Une nouvelle release a été publiée pour le projet **compute: v${{ needs.python_project.outputs.compute_version }}** :tada: :tada: :tada:\n\nRetrouvez toutes les informations sur [la page de release](${{ steps.create_release.outputs.html_url }})\",\"props\":{}\"card\":\"$(cat /tmp/changelog.md)\"}}" > mattermost.json
- name: Notify to Mattermost
# if: ${{ !env.PRERELEASE }}
run: |
${{ steps.create_release.outputs.html_url }}
curl -X POST -H 'Content-Type: application/json' -d @mattermost.json ${{ secrets.MATTERMOST_RELEASE_URL }}