Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows in CI builds #56

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
description: 'The output of the complete_version of the "determine_version" job from the build_and_release.yml workflow'
required: true
type: string
release_upload_url:
release_id:
description: 'The output of the "create_release" job from the build_and_release.yml workflow'
required: true
type: string
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
sed -i s/@@VERSION@@/${PACKAGE_VERSION}/ AppImageBuilder.yml
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DENABLE_WEBSERVER=ON -DENABLE_WEBCAM=ON -DPERFORMOUS_VERSION=$PACKAGE_VERSION ..
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCOMPOSER_VERSION=$PACKAGE_VERSION ..
make -j$(nproc) install DESTDIR=../AppDir
cd ..
appimage-builder --recipe AppImageBuilder.yml --skip-test
Expand Down Expand Up @@ -70,11 +70,9 @@ jobs:
- name: Upload artifacts to tagged release
id: upload_assets
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
uses: actions/upload-release-asset@v1
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.release_upload_url }}
asset_path: ${{ env.ARTIFACT_PATH }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: application/octet-stream
release_id: ${{ inputs.release_id }}
file: ${{ env.ARTIFACT_PATH }}
44 changes: 24 additions & 20 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ jobs:
version_tweak: ${{ steps.versioning.outputs.version_tweak }}
complete_version: ${{ steps.versioning.outputs.complete_version }}
steps:
- name: Checkout Composer
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/composer
repository: ${{ github.event.repository.full_name }}
ref: '${{ github.event.head.ref }}'
fetch-depth: 0
- name: Determine the complete version
id: versioning
run: |
# Always check the tags on master since it will have the latest.
# Tags will trigger their own workflow and version names
git clone --recursive ${{ github.server_url }}/${{ github.repository }} performous_composer
cd performous_composer
cd composer
LATEST_TAG_VERSION=$(git describe --tags --abbrev=0 || echo 1.0.0)
LATEST_FULL_TAG_VERSION=$(git describe --tags || echo 1.0.0)
echo "latest_tag_version=$(git describe --tags --abbrev=0 || echo 1.0.0)" >> $GITHUB_OUTPUT
Expand All @@ -53,7 +59,7 @@ jobs:
echo "version_minor=$(cut -d '.' -f 2 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT
echo "version_patch=$(cut -d '.' -f 3 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT
echo "version_tweak=0" >> $GITHUB_OUTPUT
echo "complete_version=$(if [ $GITHUB_REF_TYPE = 'tag' ]; then echo $GITHUB_REF_NAME; elif [ $GITHUB_REF_TYPE = 'branch' ] && [ $GITHUB_REF_NAME = 'master' ]; then echo $LATEST_FULL_TAG_VERSION-beta; elif [ $GITHUB_REF_TYPE = 'branch' ] && [ $GITHUB_REF_NAME != 'master' ]; then echo $LATEST_TAG_VERSION-${{github.event.pull_request.number}}-${GITHUB_SHA::7}-alpha; fi)" >> $GITHUB_OUTPUT
echo "complete_version=$(if [ $GITHUB_REF_TYPE = 'tag' ]; then echo $GITHUB_REF_NAME; elif [ $GITHUB_REF_TYPE = 'branch' ] && [ $GITHUB_REF_NAME = 'master' ]; then echo $LATEST_FULL_TAG_VERSION-beta; elif [ $GITHUB_REF_TYPE = 'branch' ] && [ $GITHUB_REF_NAME != 'master' ]; then echo $LATEST_TAG_VERSION-${{github.event.pull_request.number}}-$(git rev-parse --short=7 $(git describe))-alpha; fi)" >> $GITHUB_OUTPUT

# Set up a release that packages will be published to.
create_release:
Expand All @@ -62,17 +68,15 @@ jobs:
# Make sure the output variable for this step is set so it
# can be consumed by later build steps
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Create the Main release
id: create_release
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
release_name: Composer ${{ github.ref_name }}
name: Composer ${{ github.ref_name }}
draft: true
prerelease: false

Expand All @@ -82,18 +86,18 @@ jobs:
uses: ./.github/workflows/linux.yml
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_upload_url: ${{ needs.create_release.outputs.upload_url }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release

# Pull in the AppImage build workflow
AppImage_Package:
name: Build the AppImage
name: Build the AppImage package
uses: ./.github/workflows/appimage.yml
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_upload_url: ${{ needs.create_release.outputs.upload_url }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release
Expand All @@ -110,12 +114,12 @@ jobs:
# - create_release

# Pull in the Windows build workflow
#Windows_Packages:
# name: Build the Windows packages
# uses: ./.github/workflows/windows.yml
# with:
# package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
# release_upload_url: ${{ needs.create_release.outputs.upload_url }}
# needs:
# - determine_version
# - create_release
Windows_Packages:
name: Build the Windows packages
uses: ./.github/workflows/windows.yml
with:
package_complete_version: ${{ needs.determine_version.outputs.complete_version }}
release_id: ${{ needs.create_release.outputs.release_id }}
needs:
- determine_version
- create_release
52 changes: 26 additions & 26 deletions .github/workflows/build_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@
## The fourth argument is the OS name, and the fifth
## argument is the OS version, both are optional.
function package_name () {
WORK_DIR=${1}
PACKAGE_REGEX=${2}
PACKAGE_OFFICIAL_VERSION=${3}
PACKAGE_OS=${4}
PACKAGE_OS_VERSION=${5}
WORK_DIR=${1}
PACKAGE_REGEX=${2}
PACKAGE_OFFICIAL_VERSION=${3}
PACKAGE_OS=${4}
PACKAGE_OS_VERSION=${5}

if [ ${PACKAGE_OS} ]; then
PACKAGE_OS_NAME="-${PACKAGE_OS}"
fi
if [ ${PACKAGE_OS_VERSION} ]; then
PACKAGE_OS_VERSION_NAME="_${PACKAGE_OS_VERSION}"
fi
PACKAGE_PATH=$(ls ${WORK_DIR}/${PACKAGE_REGEX})
PACKAGE_NAME=$(basename ${PACKAGE_PATH})
PACKAGE_SUFFIX=$(echo ${PACKAGE_NAME} | rev | cut -d'.' -f1 | rev)
NEW_PACKAGE_NAME="Composer-${PACKAGE_OFFICIAL_VERSION}${PACKAGE_OS_NAME}${PACKAGE_OS_VERSION_NAME}.${PACKAGE_SUFFIX}"
NEW_PACKAGE_PATH="/tmp/${NEW_PACKAGE_NAME}"
MASTER_NEW_PACKAGE_NAME="Composer-latest${PACKAGE_OS_NAME}${PACKAGE_OS_VERSION_NAME}.${PACKAGE_SUFFIX}"
MASTER_NEW_PACKAGE_PATH="/tmp/${MASTER_NEW_PACKAGE_NAME}"
cp ${PACKAGE_PATH} ${MASTER_NEW_PACKAGE_PATH}
cp ${PACKAGE_PATH} ${NEW_PACKAGE_PATH}
ARTIFACT_NAME=$(basename ${NEW_PACKAGE_NAME})
MASTER_ARTIFACT_NAME=$(basename ${MASTER_NEW_PACKAGE_NAME})
echo "ARTIFACT_PATH=${NEW_PACKAGE_PATH}" >> ${GITHUB_ENV}
echo "ARTIFACT_NAME=${NEW_PACKAGE_NAME}" >> ${GITHUB_ENV}
echo "MASTER_ARTIFACT_PATH=${MASTER_NEW_PACKAGE_PATH}" >> ${GITHUB_ENV}
echo "MASTER_ARTIFACT_NAME=${MASTER_NEW_PACKAGE_NAME}" >> ${GITHUB_ENV}
if [[ "${PACKAGE_OS}" != "" ]]; then
PACKAGE_OS_NAME="-${PACKAGE_OS}"
fi
if [[ "${PACKAGE_OS_VERSION}" != "" ]]; then
PACKAGE_OS_VERSION_NAME="_${PACKAGE_OS_VERSION}"
fi
PACKAGE_PATH=$(ls ${WORK_DIR}/${PACKAGE_REGEX})
PACKAGE_NAME=$(basename ${PACKAGE_PATH})
PACKAGE_SUFFIX=$(echo ${PACKAGE_NAME} | rev | cut -d'.' -f1 | rev)
NEW_PACKAGE_NAME="Performous-${PACKAGE_OFFICIAL_VERSION}${PACKAGE_OS_NAME}${PACKAGE_OS_VERSION_NAME}.${PACKAGE_SUFFIX}"
NEW_PACKAGE_PATH="/tmp/${NEW_PACKAGE_NAME}"
MASTER_NEW_PACKAGE_NAME="Performous-latest${PACKAGE_OS_NAME}${PACKAGE_OS_VERSION_NAME}.${PACKAGE_SUFFIX}"
MASTER_NEW_PACKAGE_PATH="/tmp/${MASTER_NEW_PACKAGE_NAME}"
cp ${PACKAGE_PATH} ${MASTER_NEW_PACKAGE_PATH}
cp ${PACKAGE_PATH} ${NEW_PACKAGE_PATH}
ARTIFACT_NAME=$(basename ${NEW_PACKAGE_NAME})
MASTER_ARTIFACT_NAME=$(basename ${MASTER_NEW_PACKAGE_NAME})
echo "ARTIFACT_PATH=${NEW_PACKAGE_PATH}" >> ${GITHUB_ENV}
echo "ARTIFACT_NAME=${NEW_PACKAGE_NAME}" >> ${GITHUB_ENV}
echo "MASTER_ARTIFACT_PATH=${MASTER_NEW_PACKAGE_PATH}" >> ${GITHUB_ENV}
echo "MASTER_ARTIFACT_NAME=${MASTER_NEW_PACKAGE_NAME}" >> ${GITHUB_ENV}
}
5 changes: 3 additions & 2 deletions .github/workflows/comment_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Get the PR number
id: get_pr
run: |
# Query the issue search API to get the PR associated with it
PR_RAW=$(curl 'https://api.github.com/search/issues?q=${{ github.event.workflow_run.head_commit.id }}')
# Get the event number from the search results, which will
# be the PR number
PR_NUM=$(echo $PR_RAW | jq '.items[].number')
echo "PR_NUM=${PR_NUM}" >> ${GITHUB_ENV}
echo "PR_NUM=${PR_NUM}" >> $GITHUB_OUTPUT

- name: Comment on PR
uses: actions/github-script@v5
Expand Down Expand Up @@ -61,5 +62,5 @@ jobs:
}
body += ` \n\nThis service is provided by [nightly.link](https://github.com/oprypin/nightly.link). These artifacts will expire in 90 days and will not be available for download after that time.`;
core.info("Review thread message body:", body);
await upsertComment(owner, repo, ${{ env.PR_NUM }},
await upsertComment(owner, repo, ${{ steps.get_pr.outputs.PR_NUM }},
"nightly-link", body);
96 changes: 66 additions & 30 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
description: 'The output of the complete_version of the "determine_version" job from the build_and_release.yml workflow'
required: true
type: string
release_upload_url:
release_id:
description: 'The output of the "create_release" job from the build_and_release.yml workflow'
required: true
type: string
Expand All @@ -19,35 +19,73 @@ env:

jobs:
# Decide if we need to build the containers on this run
determine_docker_build:
determine_docker_version:
name: Determine whether to build the containers or not
runs-on: ubuntu-latest
outputs:
build_docker_containers: ${{ steps.docker_check.outputs.build_docker_containers }}
build_docker_containers: ${{ steps.version.outputs.build_docker_containers }}
build_debian_containers: ${{ steps.version.outputs.build_debian_containers }}
build_ubuntu_containers: ${{ steps.version.outputs.build_ubuntu_containers }}
build_fedora_containers: ${{ steps.version.outputs.build_fedora_containers }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build docker check
id: docker_check
- name: Determine version
id: version
run: |
# Only run the container builds when something in the docker folder or
# this workflow has changed from master, or if it was cron triggered
GIT_OUTPUT="$(git log -n 2 --stat)"
if [ $(echo ${GIT_OUTPUT} | grep -c docker/) -gt 0 ] || [ $(echo ${GIT_OUTPUT} | grep -c .github/workflows/linux.yml) -gt 0 ] || [ '${{ github.event_name }}' = 'schedule' ]; then
if [[ '${{ github.event_name }}' == 'push' ]]; then
base_version='${{ github.event.before }}'
else
base_version='origin/master'
fi
DIFF_YML=$((git rev-parse HEAD:.github/workflows/linux.yml && git diff --merge-base ${base_version} --exit-code -- .github/workflows/linux.yml) > /dev/null 2>&1 ; echo $?)
if [[ $DIFF_YML != 0 || '${{ github.event_name }}' == 'schedule' ]]; then
echo "Refresh all containers: TRUE"
echo "build_docker_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh all containers: FALSE"
echo "build_docker_containers=false" >> $GITHUB_OUTPUT
fi

DIFF_UBUNTU=$((git rev-parse HEAD:docker/Dockerfile.ubuntu HEAD:docker/build_performous.sh && git diff --merge-base ${base_version} --exit-code -- docker/Dockerfile.ubuntu docker/build_performous.sh) > /dev/null 2>&1 ; echo $?)
DIFF_DEBIAN=$((git rev-parse HEAD:docker/Dockerfile.debian HEAD:docker/build_performous.sh && git diff --merge-base ${base_version} --exit-code -- docker/Dockerfile.debian docker/build_performous.sh) > /dev/null 2>&1 ; echo $?)
DIFF_FEDORA=$((git rev-parse HEAD:docker/Dockerfile.fedora HEAD:docker/build_performous.sh && git diff --merge-base ${base_version} --exit-code -- docker/Dockerfile.fedora docker/build_performous.sh) > /dev/null 2>&1 ; echo $?)

if [[ $DIFF_UBUNTU != 0 ]]; then
echo "Refresh Ubuntu containers: TRUE"
echo "build_ubuntu_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh Ubuntu containers: FALSE"
echo "build_ubuntu_containers=false" >> $GITHUB_OUTPUT
fi

if [[ $DIFF_FEDORA != 0 ]]; then
echo "Refresh FEDORA containers: TRUE"
echo "build_fedora_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh FEDORA containers: FALSE"
echo "build_fedora_containers=false" >> $GITHUB_OUTPUT
fi

if [[ $DIFF_DEBIAN != 0 ]]; then
echo "Refresh DEBIAN containers: TRUE"
echo "build_debian_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh DEBIAN containers: FALSE"
echo "build_debian_containers=false" >> $GITHUB_OUTPUT
fi

build_packages:
name: Build the Linux packages
runs-on: ubuntu-latest
needs:
- determine_docker_build
- determine_docker_version
strategy:
matrix:
include:
Expand All @@ -59,19 +97,25 @@ jobs:
version: 10
- os: debian
version: 11
- os: fedora
version: 34
- os: debian
version: 12
- os: fedora
version: 35
## FFMPEG5 causes issues
## See https://github.com/performous/composer/issues/45
#- os: fedora
# version: 36
- os: fedora
version: 36
- os: fedora
version: 37
- os: fedora
version: 38
- os: fedora
version: 39
steps:
- name: Container name
run: |
# Figure out the container name we'll use for the build
BUILD_CONTAINER=${{ env.REGISTRY }}/${{ env.REPO_NAME }}/composer-deps:${{ matrix.os }}-${{ matrix.version }}
BUILD_CONTAINER=${{ env.REGISTRY }}/${{ env.REPO_NAME }}/deps:${{ matrix.os }}-${{ matrix.version }}
echo "CONTAINER_NAME=${BUILD_CONTAINER}" >> $GITHUB_ENV

- name: Checkout
Expand All @@ -85,7 +129,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build ${{ matrix.os }} ${{ matrix.version }} Container
if: ${{ needs.determine_docker_build.outputs.build_docker_containers == 'true' }}
if: needs.determine_docker_version.outputs[format('build_{0}_containers', matrix.os)] == 'true' || needs.determine_docker_version.outputs['build_docker_containers'] == 'true'
uses: docker/build-push-action@v3
with:
context: docker/
Expand All @@ -102,25 +146,19 @@ jobs:
# Set the correct version in cmake
PACKAGE_VERSION=${{ inputs.package_complete_version }}
EXTRA_CMAKE_ARGS="-DCOMPOSER_VERSION=${PACKAGE_VERSION}"

# Decide if we should build a 'Release' package or a 'RelWithDebInfo' (default)
# For some reason, building with 'RelWithDebInfo' (default) doesn't work
# specifically on PRs, so we'll just build Releases for everything for now
#if [ '${{ github.event_name }}' != 'pull_request' ]; then
RELEASE_TYPE="-R"
#fi
COMPOSER_RELEASE_TYPE="RelWithDebInfo"

# Only pull the container if it wasn't built locally
if [ '${{ needs.determine_docker_build.outputs.build_docker_containers }}' = 'false' ]; then
if [ '${{ needs.determine_docker_version.outputs.build_docker_containers }}' = 'false' ]; then
docker pull ${{ env.CONTAINER_NAME }}
fi

# Run the build inside the docker containers using the
# build script that was pulled inside during the build
docker run --rm -v $(pwd):/github_actions_build/ ${{ env.CONTAINER_NAME }} ./build_composer.sh -g -D /github_actions_build/ -E ${EXTRA_CMAKE_ARGS} ${RELEASE_TYPE}
docker run --env EXTRA_CMAKE_ARGS --rm -v $(pwd):/github_actions_build/ ${{ env.CONTAINER_NAME }} ./build_composer.sh -g -D /github_actions_build/ -E ${EXTRA_CMAKE_ARGS} -R ${COMPOSER_RELEASE_TYPE}

## Provided by the common build functions
package_name "$(pwd)/build" "Composer*64.*" "${PACKAGE_VERSION}" "${{ matrix.os }}" "${{ matrix.version }}"
package_name "$(pwd)/build" "Composer*Linux.*" "${PACKAGE_VERSION}" "${{ matrix.os }}" "${{ matrix.version }}"

#- name: Run unit tests
# run: |
Expand All @@ -147,20 +185,18 @@ jobs:
- name: Upload artifacts to tagged release
id: upload_assets
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
uses: actions/upload-release-asset@v1
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.release_upload_url }}
asset_path: ${{ env.ARTIFACT_PATH }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: application/octet-stream
release_id: ${{ inputs.release_id }}
file: ${{ env.ARTIFACT_PATH }}

- name: Push container
uses: docker/build-push-action@v3
# Containers can't be pushed during PRs because of the way permissions
# are delegated to secrets.GITHUB_TOKEN
if: ${{ needs.determine_docker_build.outputs.build_docker_containers == 'true' && github.event_name != 'pull_request' }}
if: ${{ needs.determine_docker_version.outputs.build_docker_containers == 'true' && github.event_name != 'pull_request' }}
with:
context: docker/
file: ./docker/Dockerfile.${{ matrix.os }}
Expand Down
Loading
Loading