Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Update dependency ruby to v3.3.0 #76

Update dependency ruby to v3.3.0

Update dependency ruby to v3.3.0 #76

---
env:
PACKAGE_NAME: sensor_mqtt
PACKAGE_DESCRIPTION: Script to publish BME280 and BLE sensor metrics over MQTT
PACKAGE_ARCH: armhf
RUST_TARGET: arm-unknown-linux-gnueabi
CARGO_USE_CROSS: true
BINARY_NAME: sensor_mqtt
name: Build, package and upload
"on":
push:
paths-ignore:
- "*.md"
- LICENSE
- rustfmt.toml
- .github/renovate.json
- .gitignore
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1
with:
toolchain: stable
target: ${{ env.RUST_TARGET }}
- name: Rust Cache
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2
- name: Install cargo tarpaulin
run: cargo install cargo-tarpaulin
- uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
with:
command: build
use-cross: ${{ env.CARGO_USE_CROSS}}
args: --release --target=${{ env.RUST_TARGET }}
- uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
name: Generate coverage
with:
command: tarpaulin
args: --out xml
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
if: always()
- name: Upload build artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: target
path: target/**/${{ env.BINARY_NAME }}
build-package:
name: Build Deb Package
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: ./packaging
bundler-cache: true
- name: Download build artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
- name: Set binary as executable
run: |
find target -name ${{ env.BINARY_NAME }} -exec chmod +x {} \;
- name: Package
working-directory: ./packaging
run: |
export DEB_VERSION="$(cat ../Cargo.toml | grep "^version = " | awk '{gsub(/"/, "", $3); print $3}')-$GITHUB_RUN_NUMBER"
bundle exec fpm -f \
-s dir \
--deb-priority optional \
--maintainer [email protected] \
--vendor [email protected] \
--license MIT \
-t deb \
-n $DEB_NAME \
--description "$APP_DESCRIPTION" \
--url $APP_URL \
--deb-changelog ../CHANGELOG.md \
--prefix / \
-a $DEB_ARCH \
-v $DEB_VERSION \
--before-install deb_scripts/before_install.sh \
--before-upgrade deb_scripts/before_upgrade.sh \
--after-remove deb_scripts/after_remove.sh \
--after-install deb_scripts/after_install.sh \
--after-upgrade deb_scripts/after_upgrade.sh \
--deb-systemd sensor_mqtt.service \
--config-files /etc/sensor_mqtt/sensor_mqtt.toml \
sensor_mqtt.toml=/etc/sensor_mqtt/sensor_mqtt.toml \
../target/arm-unknown-linux-gnueabi/release/sensor_mqtt=/usr/bin/sensor_mqtt
env:
DEB_NAME: ${{ env.PACKAGE_NAME }}
APP_DESCRIPTION: ${{ env.PACKAGE_DESCRIPTION }}
APP_URL: https://github.com/${{ github.repository }}
DEB_ARCH: ${{ env.PACKAGE_ARCH }}
- name: Upload build artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: deb-package
path: "packaging/*.deb"
publish:
name: Publish
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs: build-package
steps:
- name: Download build artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: deb-package
- name: Upload to Apt repo
env:
APT_CREDENTIALS: ${{ secrets.APT_CREDENTIALS }}
APT_KEY_PASSPHRASE: ${{ secrets.APT_KEY_PASSPHRASE }}
run: |
echo $APT_CREDENTIALS > aptly-auth
find -type f -name "*.deb" -exec curl -f --netrc-file aptly-auth -XPOST -F file=@{} https://apttoo.growse.com/api/files/sensor_mqtt \;
export result=$(curl -f --netrc-file aptly-auth -X POST https://apttoo.growse.com/api/repos/defaultrepo/file/sensor_mqtt)
echo $result
export failed=$(echo $result | jq '.FailedFiles | length')
if [[ "$failed" != "0" ]]; then exit 1; fi
curl -f --netrc-file aptly-auth -X PUT -H"Content-type: application/json" --data '{"Signing":{"Passphrase":"'"$APT_KEY_PASSPHRASE"'","Batch":true}}' https://apttoo.growse.com/api/publish/:./stablish