Skip to content

Merge pull request #278 from NebraLtd/gateway-mfr-rs/v0.5.0 #1049

Merge pull request #278 from NebraLtd/gateway-mfr-rs/v0.5.0

Merge pull request #278 from NebraLtd/gateway-mfr-rs/v0.5.0 #1049

name: Publish Python 🐍 distribution 📦 to TestPyPI
on: [push]
jobs:
build-n-publish:
name: Build and publish Python 🐍 distribution 📦 to TestPyPI
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.0"
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: Publish distribution 📦 to Test PyPI
if: github.ref == 'refs/heads/master'
run: |
poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }}
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish -r test-pypi