-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Build | ||
|
||
on: push | ||
|
||
env: | ||
PACKAGE_ROOT: pkg-src | ||
PACKAGE: raspi-fan-control | ||
DESC: "RaspberryPI Cooling Fan Control Service." | ||
MAINTAINER: "Serhii [boonya] Buinytskyi <[email protected]>" | ||
ARCH: arm64 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Retrieve latest package version | ||
run: | | ||
TYPE=$(echo ${{github.ref}} | cut -d'/' -f 2) | ||
LABEL=$(echo ${{github.ref}} | cut -d'/' -f 3) | ||
if [[ "$TYPE" == "tags" ]]; then | ||
echo "LATEST_PKG_VERSION=$LABEL" >> $GITHUB_ENV | ||
# echo "::set-output name=latest_pkg_version::$LABEL" | ||
else | ||
git fetch --tags | ||
LATEST_PKG_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))-$LABEL | ||
echo "LATEST_PKG_VERSION=$LATEST_PKG_VERSION" >> $GITHUB_ENV | ||
# echo "::set-output name=latest_pkg_version::$LATEST_PKG_VERSION" | ||
fi; | ||
- name: Create package source | ||
run: | | ||
mkdir -p ${{env.PACKAGE_ROOT}}/usr/bin | ||
cp main.py ${{env.PACKAGE_ROOT}}/usr/bin/raspi-fan-control | ||
mkdir -p ${{env.PACKAGE_ROOT}}/etc/systemd/system/ | ||
cp raspi-fan-control.service ${{env.PACKAGE_ROOT}}/etc/systemd/system/raspi-fan-control.service | ||
PYTHON_PACKAGES=$(cat requirements.txt | xargs) | ||
sed -i "s/{{python-packages}}/$PYTHON_PACKAGES/" ${{env.PACKAGE_ROOT}}/DEBIAN/postinst | ||
sed -i "s/{{python-packages}}/$PYTHON_PACKAGES/" ${{env.PACKAGE_ROOT}}/DEBIAN/postrm | ||
- name: Build package | ||
id: build | ||
uses: jiro4989/build-deb-action@v2 | ||
with: | ||
package: ${{env.PACKAGE}} | ||
desc: ${{env.DESC}} | ||
maintainer: ${{env.MAINTAINER}} | ||
package_root: ${{env.PACKAGE_ROOT}} | ||
arch: 'arm64' | ||
# version: ${{steps.vars.outputs.latest_pkg_version}} | ||
version: ${{env.LATEST_PKG_VERSION}} | ||
- name: Upload package artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: "*.deb" | ||
- name: Retrieve package name | ||
run: | | ||
PKG=$(ls *.deb) | ||
echo "PKG=$PKG" >> $GITHUB_ENV | ||
- name: Create Draft Release | ||
uses: actions/create-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
id: create_release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: true | ||
prerelease: false | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{steps.create_release.outputs.upload_url}} | ||
asset_path: ${{env.PKG}} | ||
asset_name: ${{env.PKG}} | ||
asset_content_type: application/vnd.debian.binary-package |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
pip3 install {{python-packages}} | ||
sudo systemctl daemon-reload | ||
systemctl start raspi-fan-control || echo "Can't start service" | ||
systemctl enable raspi-fan-control || echo "Can't enable service" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
pip3 uninstall {{python-packages}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
systemctl disable raspi-fan-control || echo "Can't disable service" | ||
systemctl stop raspi-fan-control || echo "Can't stop service" |
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