Skip to content

Create GitHub Release #61

Create GitHub Release

Create GitHub Release #61

Workflow file for this run

name: Create GitHub Release
on:
workflow_dispatch:
branches:
- master
pull_request:
branches:
- master
types: [closed]
env:
DEB_BUILD_DOCKER_IMAGE: "pitop/pi-top-os-deb-build"
DEB_BUILD_DOCKER_TAG: "latest"
PACKAGECLOUD_REPO: "pi-top-os-unstable"
OS: "debian"
DISTRO: "bullseye"
HOST_COMPILE: "{\"architecture\":[\"amd64\"]}"
X_COMPILE: "{\"architecture\":[\"armhf\", \"arm64\"]}" # ARM 32 and 64 bit
jobs:
check-architecture:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Determine target architecture
id: set-matrix
# If any packages define architecture as other than 'all'
# then it can't be compiled on host architecture
run: |
if grep '^Architecture:' debian/control | grep -q -v 'all'; then
echo "matrix=$X_COMPILE" >>$GITHUB_OUTPUT
else
echo "matrix=$HOST_COMPILE" >>$GITHUB_OUTPUT
fi
release:
needs: check-architecture
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.check-architecture.outputs.matrix)}}
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: Build Debian package
uses: pi-top/debian-package-build-action@master
with:
target_architecture: ${{ matrix.architecture }}
docker_image: ${{ env.DEB_BUILD_DOCKER_IMAGE }}:${{ env.DEB_BUILD_DOCKER_TAG }}
signing_key: ${{ secrets.DEB_SIGNING_GPG_KEY }}
signing_passphrase: ${{ secrets.DEB_SIGNING_GPG_PASSPHRASE }}
build_directory: ./artifacts
# Optional, repo-specific build environment variables
additional_env: |
DATA="${{ secrets.DATA }}"
TLS_KEY="${{ secrets.CERT_PRIVATE_KEY }}"
PYTHON_PACKAGE_VERSION="${{ steps.version.outputs.tag_latest_ltrimv }}"
- 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' &&
(
matrix.architecture == 'amd64' ||
matrix.architecture == 'armhf'
)
)
with:
repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ env.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 }}/${{ env.DISTRO }}
files: |
./artifacts/*.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ env.CURRENT_VERSION }}"
name: "v${{ env.CURRENT_VERSION }}"
draft: false
prerelease: false
files: ./artifacts/*
token: ${{ secrets.PAT_GITHUB }}