Repository navigation
275 lines (240 loc) · 9.43 KB
/
Copy pathrelease.yml
File metadata and controls
275 lines (240 loc) · 9.43 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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Make Release
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: write
pull-requests: write
jobs:
release_create:
# Dispatch-only: when this workflow also runs on release publish, this job
# must not fire again on that event (it would create a second bump PR).
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
new_sha: ${{ steps.commit_updated.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip3 install poetry
- name: Bump version
run: >-
poetry version patch
- name: Get version
id: get_version
run: >-
printf 'version=%s\n' "$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Create version bump PR
id: bump_pr
uses: peter-evans/create-pull-request@v8
env:
VERSION: ${{ steps.get_version.outputs.version }}
with:
# The release tag points at the bump commit, which must live on a
# durable branch. It lands on master when this PR is merged with a
# merge commit (see the PR body note about merge vs squash).
# With the default GITHUB_TOKEN the PR needs a maintainer click to
# run CI and merge; set MESHTASTIC_AUTOMATION_TOKEN for fully
# unattended operation (see update_protobufs.yml).
token: ${{ secrets.MESHTASTIC_AUTOMATION_TOKEN || secrets.GITHUB_TOKEN }}
branch: release-bump/${{ env.VERSION }}
delete-branch: true
title: "bump version to ${{ env.VERSION }}"
commit-message: "bump version to ${{ env.VERSION }}"
body: |
Automated version bump to ${{ env.VERSION }} from the *Make Release*
workflow.
The release tag for ${{ env.VERSION }} points at this commit. Merge
(not squash) so the tag stays reachable from master.
add-paths: pyproject.toml
- name: Checkout bump commit
# create-pull-request commits to the PR branch and leaves the
# workspace restored to the base branch, so HEAD here is the pre-bump
# commit. Check out the bump commit so the tag and every build in
# this workflow use the bumped version.
uses: actions/checkout@v4
with:
ref: ${{ steps.bump_pr.outputs.pull-request-head-sha }}
persist-credentials: false
- name: Record release commit
id: commit_updated
run: |
set -euo pipefail
printf 'sha=%s\n' "$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
uses: actions/create-release@v1
id: create_release
with:
draft: true
prerelease: true
release_name: Meshtastic Python ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
commitish: ${{ steps.commit_updated.outputs.sha }}
body: |
Autogenerated by github action, developer should edit as required before publishing...
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build a binary wheel and a source tarball
run: >-
poetry build
- name: Validate distributions
# Dry-run for the PyPI upload: twine check validates the metadata PyPI
# itself would reject (long descriptions, README rendering, metadata
# syntax) without uploading anything. The real upload happens when the
# GitHub release is published (publish-to-pypi job).
run: |
python -m pip install --upgrade twine
twine check dist/*
# build-and-publish-mac:
# runs-on: macos-latest
# needs: release_create
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# ref: ${{ needs.release_create.outputs.new_sha }}
# - name: Set up Python 3.12
# uses: actions/setup-python@v5
# with:
# python-version: "3.12"
# - name: Setup code signing
# env:
# MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
# MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
# MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
# run: |
# echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
# security create-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
# security default-keychain -s meshtastic.keychain
# security unlock-keychain -p "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
# security import certificate.p12 -k meshtastic.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_KEYCHAIN_PASSWORD" meshtastic.keychain
# - name: Build
# env:
# MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
# run: |
# pip install pyinstaller
# pip install -r requirements.txt
# pip install .
# pyinstaller -F -n meshtastic --collect-all meshtastic --codesign-identity "$MACOS_SIGNING_IDENTITY" meshtastic/__main__.py
# - name: Add mac to release
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ needs.release_create.outputs.upload_url }}
# asset_path: dist/meshtastic
# asset_name: meshtastic_mac
# asset_content_type: application/zip
build-and-publish-ubuntu:
# Dispatch-only, same reason as release_create.
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs: release_create
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.release_create.outputs.new_sha }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build
run: |
pip install poetry
bin/build-bin.sh
- name: Add ubuntu to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release_create.outputs.upload_url }}
asset_path: dist/meshtastic
asset_name: meshtastic_ubuntu
asset_content_type: application/zip
- name: Add readme.txt to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release_create.outputs.upload_url }}
asset_path: standalone_readme.txt
asset_name: readme.txt
asset_content_type: text/plain
# build-and-publish-windows:
# runs-on: windows-latest
# needs: release_create
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# ref: ${{ needs.release_create.outputs.new_sha }}
# - name: Set up Python 3.12
# uses: actions/setup-python@v5
# with:
# python-version: "3.12"
# - name: Build
# run: |
# pip install poetry
# bin/build-bin.sh
# - name: Add windows to release
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ needs.release_create.outputs.upload_url }}
# asset_path: dist/meshtastic.exe
# asset_name: meshtastic_windows
# asset_content_type: application/zip
publish-to-pypi:
# The real PyPI upload happens when the GitHub release is published, so
# the draft release and the merge of the bump PR come first and a human
# decides when the version goes live. Nothing is uploaded on dispatch.
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout release commit
uses: actions/checkout@v4
with:
# The release tag points at the version-bump commit.
ref: refs/tags/${{ github.event.release.tag_name }}
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build a binary wheel and a source tarball
run: |
python -m pip install --upgrade pip
pip3 install poetry
poetry build
- name: Verify built version matches the release
run: |
set -euo pipefail
BUILT_VERSION="$(poetry version --short)"
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [[ "${BUILT_VERSION}" != "${TAG_VERSION}" ]]; then
echo "::error::Built version ${BUILT_VERSION} does not match release tag ${GITHUB_REF_NAME}"
exit 1
fi
echo "Built ${BUILT_VERSION} matches release ${TAG_VERSION}"
- name: Publish to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}