-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (210 loc) · 7.35 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: Release
on:
push:
tags:
- 'v*.*'
inputs:
create_release:
description: 'Create Release'
required: false
default: 'true'
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
create_release:
description: 'Create Release'
required: false
default: 'draft'
jobs:
build-artifacts:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_num: ${{ steps.version.outputs.version_num }}
archive_filename_tar: mbuspico_${{ steps.version.outputs.version }}.tar.gz
archive_filename_zip: mbuspico_${{ steps.version.outputs.version }}.zip
archive_filename_python: mbuspico_python_${{ steps.version.outputs.version }}.zip
release_filename_uf2: mbuspico_${{ steps.version.outputs.version }}.uf2
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: version
run: |
ver=${VERSION_REF##*/}
if [[ "$ver" =~ ^v([0-9]+).([0-9]+) ]]; then
echo "version=$ver" >> $GITHUB_OUTPUT
echo "version_num=${ver:1}" >> $GITHUB_OUTPUT
else
echo "version=v0.0" >> $GITHUB_OUTPUT
echo "version_num=0.0" >> $GITHUB_OUTPUT
fi
env:
VERSION_REF: ${{ github.ref }}
shell: bash
id: version
- name: Create archive tar
run: |
mkdir -p dist/zip
tar czvf dist/$ARCHIVE_NAME --exclude-vcs --exclude-vcs-ignore --exclude='dist' .
tar xzvf dist/$ARCHIVE_NAME -C dist/zip
env:
ARCHIVE_NAME: mbuspico.tar.gz
id: create-archive-tar
- name: Upload tar-archive artifact
uses: actions/upload-artifact@v3
with:
name: artifact-archive-tar
path: dist/mbuspico.tar.gz
- name: Create archive zip
run: |
apt update && apt install -y zip
cd dist/zip
zip -r ../$ARCHIVE_NAME .
env:
ARCHIVE_NAME: mbuspico.zip
id: create-archive-zip
- name: Upload zip-archive artifact
uses: actions/upload-artifact@v3
with:
name: artifact-archive-zip
path: dist/mbuspico.zip
- name: Create archive python
run: |
cd python
zip -r ../dist/$ARCHIVE_NAME .
env:
ARCHIVE_NAME: python.zip
id: create-python-zip
- name: Upload python archive artifact
uses: actions/upload-artifact@v3
with:
name: artifact-archive-python
path: dist/python.zip
build-uf2:
runs-on: ubuntu-latest
needs:
- build-artifacts
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build uf2
uses: addnab/docker-run-action@v3
with:
image: ravenworx/pico-sdk-build:latest
options: |
-v ${{ github.workspace }}:/opt/mbuspico
run: |
/opt/mbuspico/build.sh
- name: Upload uf2 artifact
uses: actions/upload-artifact@v3
with:
name: artifact-uf2
path: build/mbuspico.uf2
docker:
runs-on: ubuntu-latest
needs:
- build-artifacts
if: ${{ needs.build-artifacts.outputs.version != 'v0.0' || (github.event.inputs && contains('true draft', github.event.inputs.create_release)) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
file: docker/python-run.Dockerfile
push: true
tags: ravenworx/mbuspico:latest, ravenworx/mbuspico:${{needs.build-artifacts.outputs.version_num}}
create-release:
runs-on: ubuntu-latest
needs:
- build-artifacts
- build-uf2
if: ${{ needs.build-artifacts.outputs.version != 'v0.0' || (github.event.inputs && contains('true draft', github.event.inputs.create_release)) }}
steps:
- uses: actions/checkout@v3
- name: Generate Changelog
id: changelog
uses: metcalfc/changelog-generator@v4.0.1
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: MBusPico ${{needs.build-artifacts.outputs.version}}
body: |
${{ steps.changelog.outputs.changelog }}
draft: ${{ github.event.inputs && github.event.inputs.create_release == 'draft' }}
prerelease: false
- name: Download tar-archive artifact
uses: actions/download-artifact@v3
with:
name: artifact-archive-tar
path: dist
- name: Download zip-archive artifact
uses: actions/download-artifact@v3
with:
name: artifact-archive-zip
path: dist
- name: Download python artifact
uses: actions/download-artifact@v3
with:
name: artifact-archive-python
path: dist
- name: Download uf2 artifact
uses: actions/download-artifact@v3
with:
name: artifact-uf2
path: dist
- name: Upload archive tar artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dist/mbuspico.tar.gz
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_tar }}
asset_content_type: application/gzip
- name: Upload archive zip artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dist/mbuspico.zip
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_zip }}
asset_content_type: application/zip
- name: Upload python artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dist/python.zip
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_python }}
asset_content_type: application/zip
- name: Upload uf2 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dist/mbuspico.uf2
asset_name: ${{ needs.build-artifacts.outputs.release_filename_uf2 }}
asset_content_type: application/octet-stream