Skip to content

Build and Deploy to Packagecloud #16

Build and Deploy to Packagecloud

Build and Deploy to Packagecloud #16

name: Build and Deploy to Packagecloud
on:
# Allow manual runs of workflow from Actions tab
workflow_dispatch:
push:
branches:
- main
paths:
- 'debian/changelog'
env:
debpackagename: wlanpi-core
jobs:
check_version:
name: Check py & deb pkg versions match
uses: WLAN-Pi/gh-workflows/.github/workflows/check-py-deb-pkg-versions-match.yml@main
with:
python_version_file_path: 'wlanpi_core/__version__.py'
format:
name: Get formatted version for filename
uses: WLAN-Pi/gh-workflows/.github/workflows/get-formatted-version-string.yml@main
sbuild:
name: sbuild ${{ matrix.distro }}+${{ matrix.arch }} pkg
runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}"
needs: [ format, check_version ]
strategy:
fail-fast: false
matrix:
distro: [ bullseye,bookworm ]
arch: [ arm64 ]
environment: PACKAGECLOUD
steps:
- name: Validate formatted version output
run: |
if [ -z "${{ needs.format.outputs.version }}" ]; then
echo "Error: formatted version output is empty."
exit 1
else
echo "Formatted version output: ${{ needs.format.outputs.version }}"
fi
- name: Get current date
id: date
run: echo "date=$(date -u +'%Y%m%d')" >> $GITHUB_ENV
- name: Gset package filename
run: |
echo "filename=${{ env.debpackagename }}_${{ needs.format.outputs.version }}~gha${{ env.date }}+${{ matrix.arch }}_${{ matrix.distro }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Validate Environment Variables
run: |
if [ -z "${{ env.debpackagename }}" ]; then
echo "Error: debpackagename cannot be empty"
exit 1
fi
shell: bash
- name: sbuild deb pkg for ${{ matrix.distro }}+${{ matrix.arch }}
uses: wlan-pi/sbuild-debian-package@main
id: build-debian-package
with:
distro: ${{ matrix.distro }}
arch: ${{ matrix.arch }}
- name: Archive artifacts and upload to GitHub
uses: actions/upload-artifact@v4
with:
name: ${{ env.filename }}
path: ${{ steps.build-debian-package.outputs.deb-package }}
- name: Upload arm64 pkg to debian/${{ matrix.distro }}
if: ${{ matrix.arch == 'arm64' }}
uses: danielmundi/upload-packagecloud@main
with:
package-name: ${{ steps.build-debian-package.outputs.deb-package }}
packagecloud-username: rgnets_mdk
packagecloud-repo: wlanpi-dev
packagecloud-distrib: debian/${{ matrix.distro }}
packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }}
slack-workflow-status:
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }}
name: Post workflow status to Slack
needs:
- sbuild
runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}"
steps:
- name: Slack Workflow Notification
uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}