This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
chore(deps): lock file maintenance #301
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1 | |
with: | |
toolchain: stable | |
target: ${{ env.RUST_TARGET }} | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2 | |
- uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1 | |
with: | |
command: build | |
use-cross: ${{ env.CARGO_USE_CROSS}} | |
args: --release --target=${{ env.RUST_TARGET }} | |
- name: Upload build artifact | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4 | |
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@a5ac7e51b41094c92402da3b24376905380afc29 # 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@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4 | |
- 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@65462800fd760344b1a7b4382951275a0abb4808 # v4 | |
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@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4 | |
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 |