Add disk space to OS image on CI to avoid running out of space #21
Workflow file for this run
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: Create GitHub Release | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
- bullseye | |
types: [closed] | |
env: | |
DEB_BUILD_DOCKER_IMAGE: "pitop/pi-top-os-deb-build" | |
DEB_BUILD_DOCKER_BRANCH: "master" | |
PACKAGECLOUD_REPO: "pi-top-os-unstable" | |
OS: "debian" | |
HOST_COMPILE: "\"architecture\":[\"amd64\"]" | |
X_COMPILE: "\"architecture\":[\"armhf\", \"arm64\"]" # ARM 32 and 64 bit | |
jobs: | |
check-architecture: | |
runs-on: ubuntu-20.04 | |
outputs: | |
architecture: ${{ steps.set-arch.outputs.architecture }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Determine target architecture | |
id: set-arch | |
# If any packages define architecture as other than 'all' | |
# then it can't be compiled on host architecture | |
run: | | |
architecture=$HOST_COMPILE | |
if grep '^Architecture:' debian/control | grep -q -v 'all'; then | |
architecture=$X_COMPILE | |
fi | |
echo "Building for $architecture" | |
echo "architecture=$architecture">>$GITHUB_OUTPUT | |
check-distro: | |
runs-on: ubuntu-20.04 | |
outputs: | |
distros: ${{ steps.set-distros.outputs.distros }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Determine build distro | |
id: set-distros | |
run: | | |
distros="\"distro\":[\"bookworm\", \"bullseye\"]" | |
# if bullseye branch exists, build for bookworm only | |
if git branch -r | grep -Eq "origin/bullseye$"; then | |
distros="\"distro\":[\"bookworm\"]" | |
fi | |
# if pull request to bullseye branch or current branch is bullseye, build only for bullseye | |
if [ $(echo ${{ github.head_ref }} | grep -qE "bullseye$") ] || [ ${{ github.ref }} = 'refs/heads/bullseye' ]; then | |
distros="\"distro\":[\"bullseye\"]" | |
fi | |
echo "Building for $distros" | |
echo "distros=$distros">>$GITHUB_OUTPUT | |
set-build-matrix: | |
needs: [check-distro, check-architecture] | |
runs-on: ubuntu-20.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Determine build matrix | |
id: set-matrix | |
run: | | |
matrix='{${{needs.check-distro.outputs.distros}}, ${{needs.check-architecture.outputs.architecture}}}' | |
echo "Building for $matrix" | |
echo "matrix=$matrix">>$GITHUB_OUTPUT | |
check-versions: | |
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged && github.head_ref == 'bump-changelog') | |
runs-on: ubuntu-20.04 | |
outputs: | |
CURRENT_VERSION: ${{ steps.current_version.outputs.CURRENT_VERSION }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Get latest semver tag and latest version in changelog | |
run: | | |
set -x | |
sudo apt update | |
sudo apt install -y --no-install-recommends dpkg-dev npm | |
npm install -g git-latest-semver-tag | |
latest_tag=$(git-latest-semver-tag) | |
changelog_version=$(dpkg-parsechangelog -Sversion) | |
echo "LATEST_TAG=${latest_tag#v}" >> $GITHUB_ENV | |
echo "CURRENT_VERSION=${changelog_version}" >> $GITHUB_ENV | |
- name: Confirm version is higher than last tagged version | |
if: ${{ env.LATEST_TAG != '' }} | |
run: dpkg --compare-versions ${{ env.CURRENT_VERSION }} gt ${{ env.LATEST_TAG }} | |
- name: Set current version as output | |
id: current_version | |
run: | |
echo "CURRENT_VERSION=${{ env.CURRENT_VERSION }}">>"$GITHUB_OUTPUT" | |
release: | |
needs: [set-build-matrix, check-versions] | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged && github.head_ref == 'bump-changelog') | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJSON(needs.set-build-matrix.outputs.matrix)}} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Patch lintian-overrides | |
if: matrix.distro == 'bullseye' | |
run: | |
cp -r debian/bullseye-overrides/* debian/ || true | |
- name: Build Debian package | |
uses: pi-top/debian-package-build-action@master | |
with: | |
# https://github.com/pi-top/debian-package-build-action/pull/19 | |
# lintian_check_changelog_spelling: false | |
target_architecture: ${{ matrix.architecture }} | |
docker_image: ${{ env.DEB_BUILD_DOCKER_IMAGE }}:${{ matrix.distro }}-${{ env.DEB_BUILD_DOCKER_BRANCH }} | |
signing_key: ${{ secrets.DEB_SIGNING_GPG_KEY }} | |
signing_passphrase: ${{ secrets.DEB_SIGNING_GPG_PASSPHRASE }} | |
build_directory: ./artifacts | |
LINTIAN_SHOW_OVERRIDES: 0 | |
# Optional, repo-specific build environment variables | |
additional_env: | | |
DATA="${{ secrets.DATA }}" | |
TLS_KEY="${{ secrets.CERT_PRIVATE_KEY }}" | |
PYTHON_PACKAGE_VERSION="${{ needs.check-versions.outputs.CURRENT_VERSION }}" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "dsc" | |
path: "./artifacts" | |
- name: Upload .dsc to PackageCloud | |
uses: pi-top/ghaction-packagecloud@main | |
# Only 1 .dsc is required for source so take armhf if there's multiple | |
if: | | |
( | |
( | |
github.ref == 'refs/heads/master' || | |
github.ref == 'refs/heads/bullseye' | |
) && | |
( | |
matrix.architecture == 'amd64' || | |
matrix.architecture == 'armhf' | |
) | |
) | |
with: | |
repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ matrix.distro }} | |
files: | | |
./artifacts/*.dsc | |
env: | |
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} | |
- name: Upload .deb to PackageCloud | |
uses: pi-top/ghaction-packagecloud@main | |
with: | |
repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ matrix.distro }} | |
files: | | |
./artifacts/*.deb | |
env: | |
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} | |
- name: Install zip | |
uses: montudor/action-zip@v1 | |
- name: Zip distro artifacts | |
run: | | |
ls -l ./artifacts | |
zip ${{ matrix.distro }}-${{ matrix.architecture }}.deb.zip ./artifacts/* | |
- name: Set release tag | |
run: | | |
release_tag="v${{ needs.check-versions.outputs.CURRENT_VERSION }}" | |
matrix="${{needs.set-build-matrix.outputs.matrix}}" | |
# if releasing ONLY for bullseye, prepend 'bullseye' to release tag | |
if [ ${{ matrix.distro }} = 'bullseye' ] && echo "${matrix}" | grep -qv 'bookworm'; then | |
release_tag="bullseye-$release_tag" | |
fi | |
echo "RELEASE_TAG=${release_tag}" >> $GITHUB_ENV | |
- name: Create release and upload package | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.PAT_GITHUB }} | |
file: ./${{ matrix.distro}}-${{ matrix.architecture }}.deb.zip | |
tag: ${{ env.RELEASE_TAG }} |