-
-
Notifications
You must be signed in to change notification settings - Fork 17
103 lines (89 loc) · 4.54 KB
/
publish-to-pypi.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
name: Publish Python 🐍 distribution 📦 to PyPI
on:
release:
types: [created]
workflow_dispatch:
jobs:
build-n-publish:
name: Build and publish Python 🐍 distribution 📦 to PyPI
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Fetch gateway-mfr-rs
env:
GATEWAY_MFR_RS_RELEASE: "v0.5.4"
run: |
wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf.tar.gz"
wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf.checksum"
wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu.tar.gz"
wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu.checksum"
wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-x86_64-unknown-debian-gnu.tar.gz"
wget "https://github.com/helium/gateway-mfr-rs/releases/download/${GATEWAY_MFR_RS_RELEASE}/gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-x86_64-unknown-debian-gnu.checksum"
SHA256_ARM=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf.tar.gz" | awk '{print $1}')
SHA256_AARCH64=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu.tar.gz" | awk '{print $1}')
SHA256_X86_64=$( shasum -a 256 "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-x86_64-unknown-debian-gnu.tar.gz" | awk '{print $1}')
echo "Generated checksum ARM: ${SHA256_ARM}"
echo "Generated checksum AARCH64: ${SHA256_AARCH64}"
echo "Generated checksum X86_64: ${SHA256_X86_64}"
# Verify the checksums
if grep -q "${SHA256_ARM}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf.checksum" && grep -q "${SHA256_AARCH64}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu.checksum" && grep -q "${SHA256_X86_64}" "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-x86_64-unknown-debian-gnu.checksum"; then
echo "Checksum verified for gateway_mfr. Unpacking tarball..."
# Unpack the tarballs
tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-arm-unknown-linux-gnueabihf.tar.gz"
mv gateway_mfr gateway_mfr_arm
tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-aarch64-unknown-linux-gnu.tar.gz"
mv gateway_mfr gateway_mfr_aarch64
tar -xvf "gateway-mfr-${GATEWAY_MFR_RS_RELEASE}-x86_64-unknown-debian-gnu.tar.gz"
mv gateway_mfr gateway_mfr_x86_64
exit 0
else
echo "Checksum does not match. Please check download manually and rerun!"
exit 1
fi
- name: Change permissions on gateway_mfr
run: |
chmod +x gateway_mfr_arm
chmod +x gateway_mfr_aarch64
chmod +x gateway_mfr_x86_64
- name: Move gateway_mfr in place
run: |
mv gateway_mfr_arm hm_pyhelper/gateway_mfr
mv gateway_mfr_aarch64 hm_pyhelper/gateway_mfr_aarch64
mv gateway_mfr_x86_64 hm_pyhelper/gateway_mfr_x86_64
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.4.2
- name: Install dependencies
run: |
poetry install
- name: Build a binary wheel and a source tarball
run: |
poetry build
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./dist/*
- name: Get Latest Release
id: latest_version
uses: abatilo/[email protected]
with:
owner: NebraLtd
repo: hm-pyhelper
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./dist/*
tag: ${{ steps.latest_version.outputs.latest_tag }}
overwrite: true
file_glob: true
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
poetry publish