Skip to content

Workflow file for this run

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