Skip to content

Commit

Permalink
chore: Add reusable workflow for release builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Feb 12, 2025
1 parent 2e1c5ab commit ef3b14d
Show file tree
Hide file tree
Showing 58 changed files with 2,709 additions and 31 deletions.
84 changes: 84 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
# Language
Standard: Cpp11

# Indentation
IndentWidth: 4
ContinuationIndentWidth: 4
AccessModifierOffset: -4
IndentCaseLabels: false
NamespaceIndentation: None

# Spacing
UseTab: Never
SpaceBeforeParens: ControlStatements
SpacesBeforeTrailingComments: 1
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInCStyleCastParentheses: false
SpaceBeforeAssignmentOperators: true
MaxEmptyLinesToKeep: 2

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true

# Argument Packing
BinPackArguments: true
BinPackParameters: true

# Break handling
ColumnLimit: 100
BreakBeforeBraces: Mozilla
BreakBeforeBinaryOperators: NonAssignment
BreakConstructorInitializersBeforeComma: true
AlwaysBreakTemplateDeclarations: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true

# Break penalities
PenaltyBreakBeforeFirstCallParameter: 200
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 5
PenaltyReturnTypeOnItsOwnLine: 60

# Includes
SortIncludes: true
IncludeIsMainRegex: '([-_](test|fuzz_test))?$'
IncludeBlocks: Regroup
IncludeCategories:
# Match local headers
- Regex: '^"[[:alnum:]_]+\.h"$'
Priority: 1
# Match project headers
- Regex: '^"[[:alnum:]_]+/.+\.h"$'
Priority: 2
# Match Qt headers
- Regex: '^<Q[[:alnum:]_/]+>$'
Priority: 3
# Match other headers
- Regex: '.*'
Priority: 4

# Short blocks
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty

# Set pointer format
DerivePointerAlignment: false
PointerAlignment: Left

# "const X" instead of "X const"
QualifierAlignment: Left
...
75 changes: 75 additions & 0 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build, test, and deploy

on:
# Run this workflow every day at 3:00 UTC to update caches.
schedule: [cron: '0 3 * * *']
# Allow manual trigger.
workflow_dispatch:
pull_request:
branches: ["master"]
push:
branches: ["master"]
tags: ["v*"]

# Cancel old PR builds when pushing new commits.
concurrency:
group: build-test-deploy-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

#############################################################
# Preparation jobs
#############################################################

prepare:
name: Prepare
uses: ./.github/workflows/deploy-prepare.yml

#############################################################
# Build, test, and deploy jobs (PR and push)
#############################################################

android:
name: Android
uses: ./.github/workflows/deploy-android.yml
needs: [prepare]
with:
project-name: DebugTox
production: true

appimage:
name: AppImage
uses: ./.github/workflows/deploy-appimage.yml
needs: [prepare]
with:
project-name: DebugTox
smoke-test: test/smoke-test.sh
test-files: test/smoke-test.sh

flatpak:
name: Flatpak
uses: ./.github/workflows/deploy-flatpak.yml
needs: [prepare]
with:
project-name: DebugTox
smoke-test: test/smoke-test.sh
test-files: test/smoke-test.sh

macos:
name: macOS
uses: ./.github/workflows/deploy-macos.yml
needs: [prepare]
with:
project-name: DebugTox
smoke-test: test/smoke-test.sh
test-files: test/smoke-test.sh

windows:
name: Windows
uses: ./.github/workflows/deploy-windows.yml
needs: [prepare]
with:
project-name: DebugTox
smoke-test: test/smoke-test.sh
test-files: test/smoke-test.sh
121 changes: 121 additions & 0 deletions .github/workflows/deploy-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
on:
workflow_call:
inputs:
project-name:
description: 'Name of the application to build (e.g. qTox)'
required: true
type: string
cmake-args:
description: 'Arguments to pass to CMake'
required: false
type: string
production:
description: |
Whether to upload the release to the GitHub release page, i.e.
the Android build is of production quality. If false, the build
will be uploaded to the nightly release page only.
required: false
type: boolean
default: false

jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: write
strategy:
matrix:
arch: [armeabi-v7a, arm64-v8a]
build-type: [Debug, Release]
version: [6.2.4, 6.8.1]
exclude:
- arch: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') && 'armeabi-v7a' }}
- build-type: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') || contains(github.ref, 'refs/tags/v')) && 'Debug' }}
- version: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') && '6.8.1' }}
steps:
- name: Compute values for remaining steps
id: computed
run: |
ARTIFACT_TYPE="$(echo '${{ matrix.build-type }}' | tr '[:upper:]' '[:lower:]')"
echo "artifact_type=$ARTIFACT_TYPE" >>$GITHUB_OUTPUT
if [ "${{ matrix.version }}" == "6.2.4" ]; then
SUFFIX="-android7"
echo "built_apk=_build/android-build/build/outputs/apk/debug/android-build-debug.apk" >>$GITHUB_OUTPUT
else
SUFFIX=""
echo "built_apk=_build/android-build/build/outputs/apk/$ARTIFACT_TYPE/android-build-$ARTIFACT_TYPE-signed.apk" >>$GITHUB_OUTPUT
fi
echo "suffix=$SUFFIX" >>$GITHUB_OUTPUT
echo "nightly_apk=${{ inputs.project-name }}-nightly-${{ matrix.arch }}-$ARTIFACT_TYPE$SUFFIX.apk" >>$GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch build scripts
run: |
git clone --depth=1 https://github.com/TokTok/dockerfiles "third_party/dockerfiles"
cp third_party/dockerfiles/docker-compose.yml .
- name: Determine artifact file name
id: artifact
run: |
ARTIFACT="${{ steps.computed.outputs.built_apk }}"
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-android-${{ matrix.arch }}-${{ matrix.build-type }}-${{ matrix.version }}" >>$GITHUB_OUTPUT
- name: Cache compiler output
uses: actions/cache@v4
with:
path: ".cache/ccache"
key: ${{ github.job }}-android-${{ matrix.arch }}-${{ matrix.build-type }}-${{ matrix.version }}-ccache
- name: Run build
run: docker compose run
--rm
android_builder.${{ matrix.arch }}.${{ steps.computed.outputs.artifact_type }}_${{ matrix.version }}
platform/android/cross-compile/build.sh
--arch ${{ matrix.arch }}
--build-type ${{ matrix.build-type }}
--
${{ inputs.cmake-args }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.artifact-ref }}
path: |
${{ steps.artifact.outputs.artifact }}
${{ steps.artifact.outputs.artifact }}.sha256
if-no-files-found: error
- name: Get tag name for Android release file name
if: contains(github.ref, 'refs/tags/v')
id: get_version
run: |
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
echo "release_apk=${{ inputs.project-name }}-$VERSION-${{ matrix.arch }}-${{ steps.computed.outputs.artifact_type }}${{ steps.computed.outputs.suffix }}.apk" >>$GITHUB_OUTPUT
- name: Rename Android APK for release upload
if: contains(github.ref, 'refs/tags/v')
run: |
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.get_version.outputs.release_apk }}"
sha256sum "${{ steps.get_version.outputs.release_apk }}" > "${{ steps.get_version.outputs.release_apk }}.sha256"
- name: Upload to versioned release
if: inputs.production && contains(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "${{ steps.get_version.outputs.release_apk }},${{ steps.get_version.outputs.release_apk }}.sha256"
- name: Rename Android APK for nightly upload
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.computed.outputs.nightly_apk }}"
sha256sum "${{ steps.computed.outputs.nightly_apk }}" > "${{ steps.computed.outputs.nightly_apk }}.sha256"
- name: Upload to nightly release
uses: ncipollo/release-action@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
allowUpdates: true
tag: nightly
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
prerelease: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "${{ steps.computed.outputs.nightly_apk }},${{ steps.computed.outputs.nightly_apk }}.sha256"
Loading

0 comments on commit ef3b14d

Please sign in to comment.