Add option to calculate a UPS power value when none available - "UPS_POWER_FROM_LOAD_PERCENTAGE" #134
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
name: CI | |
on: | |
push: | |
branches: ["*"] | |
pull_request: | |
branches: ["*"] | |
release: | |
types: [published] | |
workflow_dispatch: {} | |
env: | |
CARGO_TERM_COLOR: always | |
DOCKER_BUILD_PLATFORMS: >- | |
linux/386, | |
linux/amd64, | |
linux/arm/v6, | |
linux/arm/v7, | |
linux/arm64/v8, | |
DOCKER_REPO: hon95/prometheus-nut-exporter | |
jobs: | |
check: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Add dependencies | |
run: rustup component add clippy | |
- name: Build | |
run: cargo build --verbose | |
- name: Check code | |
run: manage/check.sh | |
- name: Run integration test | |
run: manage/integration_test.sh | |
publish-bleeding: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
needs: check | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Update version | |
run: echo "version=$(echo 0.0.0-SNAPSHOT+$(TZ=Etc/GMT date "+%Y-%m-%dT%H:%M:%SZ"))" | tee -a $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: ${{ env.DOCKER_BUILD_PLATFORMS }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push to Docker Hub | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
APP_VERSION=${{ env.version }} | |
platforms: ${{ env.DOCKER_BUILD_PLATFORMS }} | |
tags: | | |
${{ env.DOCKER_REPO }}:latest | |
${{ env.DOCKER_REPO }}:bleeding | |
push: true | |
publish-stable: | |
if: github.event_name == 'release' && github.event.action == 'published' && startsWith(github.ref, 'refs/tags/v') | |
needs: check | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Extract version | |
run: | | |
# Get version from git tag | |
VERSION="$(echo ${GITHUB_REF#refs/tags/v})" | |
echo "version=$VERSION" | tee -a $GITHUB_ENV | |
# Check if semantic version (3 numbers, ignore pre-release and metadata) | |
echo $VERSION | grep -Po '^\d+\.\d+\.\d+' | |
# Extract other version representations | |
echo "version_major=$(echo $VERSION | grep -Po '^\d+')" | tee -a $GITHUB_ENV | |
echo "version_minor=$(echo $VERSION | grep -Po '^\d+\.\d+')" | tee -a $GITHUB_ENV | |
echo "version_patch=$(echo $VERSION | grep -Po '^\d+\.\d+\.\d+')" | tee -a $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: ${{ env.DOCKER_BUILD_PLATFORMS }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push to Docker Hub | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
APP_VERSION=${{ env.version }} | |
platforms: ${{ env.DOCKER_BUILD_PLATFORMS }} | |
tags: | | |
${{ env.DOCKER_REPO }}:latest | |
${{ env.DOCKER_REPO }}:${{ env.version_major }} | |
${{ env.DOCKER_REPO }}:${{ env.version_minor }} | |
${{ env.DOCKER_REPO }}:${{ env.version_patch }} | |
${{ env.DOCKER_REPO }}:stable | |
push: true |