Skip to content

Commit e2ce075

Browse files
committed
feat: Add Qt application deploy workflows.
1 parent 6012b89 commit e2ce075

7 files changed

Lines changed: 958 additions & 0 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
project-name:
5+
description: 'Name of the application to build (e.g. qTox)'
6+
required: true
7+
type: string
8+
cmake-args:
9+
description: 'Arguments to pass to CMake'
10+
required: false
11+
type: string
12+
production:
13+
description: |
14+
Whether to upload the release to the GitHub release page, i.e.
15+
the Android build is of production quality. If false, the build
16+
will be uploaded to the nightly release page only.
17+
required: false
18+
type: boolean
19+
default: false
20+
21+
jobs:
22+
build:
23+
name: Build
24+
runs-on: ubuntu-24.04
25+
permissions:
26+
contents: write
27+
strategy:
28+
matrix:
29+
arch: [armeabi-v7a, arm64-v8a]
30+
build-type: [Debug, Release]
31+
version: [6.2.4, 6.8.1]
32+
exclude:
33+
- arch: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') && 'armeabi-v7a' }}
34+
- build-type: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') || contains(github.ref, 'refs/tags/v')) && 'Debug' }}
35+
- version: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') && '6.8.1' }}
36+
steps:
37+
- name: Compute values for remaining steps
38+
id: computed
39+
run: |
40+
ARTIFACT_TYPE="$(echo '${{ matrix.build-type }}' | tr '[:upper:]' '[:lower:]')"
41+
echo "artifact_type=$ARTIFACT_TYPE" >>$GITHUB_OUTPUT
42+
if [ "${{ matrix.version }}" == "6.2.4" ]; then
43+
SUFFIX="-android7"
44+
echo "built_apk=_build/android-build/build/outputs/apk/debug/android-build-debug.apk" >>$GITHUB_OUTPUT
45+
else
46+
SUFFIX=""
47+
echo "built_apk=_build/android-build/build/outputs/apk/$ARTIFACT_TYPE/android-build-$ARTIFACT_TYPE-signed.apk" >>$GITHUB_OUTPUT
48+
fi
49+
echo "suffix=$SUFFIX" >>$GITHUB_OUTPUT
50+
echo "nightly_apk=${{ inputs.project-name }}-nightly-${{ matrix.arch }}-$ARTIFACT_TYPE$SUFFIX.apk" >>$GITHUB_OUTPUT
51+
echo "docker_image=android_builder.${{ matrix.arch }}.${ARTIFACT_TYPE}_${{ matrix.version }}" >>$GITHUB_OUTPUT
52+
- uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
- name: Fetch build scripts
56+
run: |
57+
git clone --depth=1 https://github.com/TokTok/dockerfiles "third_party/dockerfiles"
58+
cp third_party/dockerfiles/docker-compose.yml .
59+
- name: Determine artifact file name
60+
id: artifact
61+
run: |
62+
ARTIFACT="${{ steps.computed.outputs.built_apk }}"
63+
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
64+
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-android-${{ matrix.arch }}-${{ matrix.build-type }}-${{ matrix.version }}" >>$GITHUB_OUTPUT
65+
- name: Cache compiler output
66+
uses: actions/cache@v4
67+
with:
68+
path: .cache/ccache
69+
key: ${{ github.job }}-android-${{ matrix.arch }}-${{ matrix.build-type }}-${{ matrix.version }}-ccache
70+
- name: Download Docker image
71+
run: docker compose run --rm ${{ steps.computed.outputs.docker_image }} uname -a
72+
- name: Run build
73+
run: docker compose run
74+
--rm
75+
${{ steps.computed.outputs.docker_image }}
76+
platform/android/cross-compile/build.sh
77+
--arch ${{ matrix.arch }}
78+
--build-type ${{ matrix.build-type }}
79+
--
80+
${{ inputs.cmake-args }}
81+
- name: Upload artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: ${{ steps.artifact.outputs.artifact-ref }}
85+
path: |
86+
${{ steps.artifact.outputs.artifact }}
87+
${{ steps.artifact.outputs.artifact }}.sha256
88+
if-no-files-found: error
89+
- name: Get tag name for Android release file name
90+
if: contains(github.ref, 'refs/tags/v')
91+
id: get_version
92+
run: |
93+
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
94+
echo "release_apk=${{ inputs.project-name }}-$VERSION-${{ matrix.arch }}-${{ steps.computed.outputs.artifact_type }}${{ steps.computed.outputs.suffix }}.apk" >>$GITHUB_OUTPUT
95+
- name: Rename Android APK for release upload
96+
if: contains(github.ref, 'refs/tags/v')
97+
run: |
98+
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.get_version.outputs.release_apk }}"
99+
sha256sum "${{ steps.get_version.outputs.release_apk }}" > "${{ steps.get_version.outputs.release_apk }}.sha256"
100+
- name: Upload to versioned release
101+
if: inputs.production && contains(github.ref, 'refs/tags/v')
102+
uses: ncipollo/release-action@v1
103+
with:
104+
allowUpdates: true
105+
draft: true
106+
token: ${{ secrets.GITHUB_TOKEN }}
107+
artifacts: "${{ steps.get_version.outputs.release_apk }},${{ steps.get_version.outputs.release_apk }}.sha256"
108+
- name: Rename Android APK for nightly upload
109+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
110+
run: |
111+
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.computed.outputs.nightly_apk }}"
112+
sha256sum "${{ steps.computed.outputs.nightly_apk }}" > "${{ steps.computed.outputs.nightly_apk }}.sha256"
113+
- name: Upload to nightly release
114+
uses: ncipollo/release-action@v1
115+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
116+
with:
117+
allowUpdates: true
118+
tag: nightly
119+
omitBodyDuringUpdate: true
120+
omitNameDuringUpdate: true
121+
prerelease: true
122+
replacesArtifacts: true
123+
token: ${{ secrets.GITHUB_TOKEN }}
124+
artifacts: "${{ steps.computed.outputs.nightly_apk }},${{ steps.computed.outputs.nightly_apk }}.sha256"
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
project-name:
5+
description: 'Name of the application to build (e.g. qTox)'
6+
required: true
7+
type: string
8+
cmake-args:
9+
description: 'Arguments to pass to CMake'
10+
required: false
11+
type: string
12+
screenshot:
13+
description: |
14+
Whether the smoke-test will output a screenshot. If true, the
15+
screenshot will be uploaded as an artifact. The smoke-test script
16+
must output the screenshot to the file named by the
17+
$QTOX_SCREENSHOT environment variable.
18+
required: false
19+
type: boolean
20+
smoke-test:
21+
description: 'Command to run to smoke test the AppImage'
22+
required: true
23+
type: string
24+
test-files:
25+
description: |
26+
List of test files needed to checkout from the repository. If your
27+
smoke-test script is local to the repository, it needs to be
28+
listed here.
29+
required: false
30+
type: string
31+
32+
jobs:
33+
build:
34+
name: Build on Alpine
35+
strategy:
36+
matrix:
37+
arch: [x86_64]
38+
runs-on: ubuntu-24.04
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
- name: Fetch build scripts
44+
run: |
45+
git clone --depth=1 https://github.com/TokTok/dockerfiles "third_party/dockerfiles"
46+
cp third_party/dockerfiles/docker-compose.yml .
47+
- name: Determine artifact file name
48+
id: artifact
49+
run: |
50+
ARTIFACT="${{ inputs.project-name }}-$(git rev-parse --short HEAD | head -c7)-${{ matrix.arch }}.AppImage"
51+
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
52+
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-appimage-${{ matrix.arch }}" >>$GITHUB_OUTPUT
53+
- name: Cache compiler output
54+
uses: actions/cache@v4
55+
with:
56+
path: .cache/ccache
57+
key: ${{ github.job }}-appimage-ccache
58+
- name: Download Docker image
59+
run: docker compose run --rm alpine-appimage uname -a
60+
- name: Run build
61+
run: docker compose run
62+
--rm
63+
-e GITHUB_REPOSITORY="$GITHUB_REPOSITORY"
64+
-e GITHUB_REF="$GITHUB_REF"
65+
alpine-appimage
66+
platform/appimage/build.sh
67+
--arch ${{ matrix.arch }}
68+
--src-dir /qtox
69+
--project-name ${{ inputs.project-name }}
70+
--
71+
${{ inputs.cmake-args }}
72+
73+
- name: Upload artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: ${{ steps.artifact.outputs.artifact-ref }}
77+
path: |
78+
${{ steps.artifact.outputs.artifact }}
79+
${{ steps.artifact.outputs.artifact }}.sha256
80+
${{ steps.artifact.outputs.artifact }}.zsync
81+
if-no-files-found: error
82+
- name: Get tag name for release file name
83+
if: contains(github.ref, 'refs/tags/v')
84+
id: get_version
85+
run: |
86+
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
87+
echo "release_artifact=${{ inputs.project-name }}-$VERSION-${{ matrix.arch }}.AppImage" >>$GITHUB_OUTPUT
88+
- name: Rename artifact for release upload
89+
if: contains(github.ref, 'refs/tags/v')
90+
run: |
91+
cp "${{ steps.artifact.outputs.artifact }}" "${{ steps.get_version.outputs.release_artifact }}"
92+
cp "${{ steps.artifact.outputs.artifact }}.sha256" "${{ steps.get_version.outputs.release_artifact }}.sha256"
93+
cp "${{ steps.artifact.outputs.artifact }}.zsync" "${{ steps.get_version.outputs.release_artifact }}.zsync"
94+
- name: Upload to versioned release
95+
if: contains(github.ref, 'refs/tags/v')
96+
uses: ncipollo/release-action@v1
97+
with:
98+
allowUpdates: true
99+
draft: true
100+
artifacts: "${{ steps.get_version.outputs.release_artifact }},${{ steps.get_version.outputs.release_artifact }}.sha256,${{ steps.get_version.outputs.release_artifact }}.zsync"
101+
- name: Rename artifact for nightly upload
102+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
103+
run: |
104+
cp "${{ steps.artifact.outputs.artifact }}" "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage"
105+
cp "${{ steps.artifact.outputs.artifact }}.sha256" "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.sha256"
106+
cp "${{ steps.artifact.outputs.artifact }}.zsync" "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.zsync"
107+
- name: Upload to nightly release
108+
uses: ncipollo/release-action@v1
109+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
110+
with:
111+
allowUpdates: true
112+
tag: nightly
113+
omitBodyDuringUpdate: true
114+
omitNameDuringUpdate: true
115+
prerelease: true
116+
replacesArtifacts: true
117+
artifacts: "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage,${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.sha256,${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.zsync"
118+
119+
test:
120+
name: Test on Ubuntu
121+
needs: [build]
122+
strategy:
123+
matrix:
124+
arch: [x86_64]
125+
runs-on: ubuntu-22.04
126+
steps:
127+
- if: inputs.test-files
128+
uses: actions/checkout@v4
129+
with:
130+
# Fetch tags if we're not already in a tag build.
131+
fetch-tags: ${{ !contains(github.ref, 'refs/tags/v') }}
132+
sparse-checkout: ${{ inputs.test-files }}
133+
- name: Determine artifact file name
134+
id: artifact
135+
run: |
136+
ARTIFACT="${{ inputs.project-name }}-$(git rev-parse --short HEAD | head -c7)-${{ matrix.arch }}.AppImage"
137+
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
138+
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-appimage-${{ matrix.arch }}" >>$GITHUB_OUTPUT
139+
- name: Download artifact from build step
140+
uses: actions/download-artifact@v4
141+
with:
142+
name: ${{ steps.artifact.outputs.artifact-ref }}
143+
- name: Run AppImage
144+
id: run
145+
run: |
146+
chmod +x ${{ steps.artifact.outputs.artifact }}
147+
${{ inputs.smoke-test }} xvfb-run --auto-servernum ./${{ steps.artifact.outputs.artifact }}
148+
echo "screenshot=$QTOX_SCREENSHOT" >>$GITHUB_OUTPUT
149+
env:
150+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151+
QTOX_SCREENSHOT: ${{ inputs.screenshot && format('{0}-AppImage-{1}.png', inputs.project-name, matrix.arch) }}
152+
- name: Upload screenshot artifact
153+
if: inputs.screenshot
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: ${{ steps.run.outputs.screenshot }}
157+
path: ${{ steps.run.outputs.screenshot }}
158+
if-no-files-found: error
159+
- name: Upload screenshot to nightly release
160+
if: inputs.screenshot && github.event_name == 'push' && github.ref == 'refs/heads/master'
161+
uses: ncipollo/release-action@v1
162+
with:
163+
allowUpdates: true
164+
tag: nightly
165+
omitBodyDuringUpdate: true
166+
omitNameDuringUpdate: true
167+
prerelease: true
168+
replacesArtifacts: true
169+
artifacts: ${{ steps.run.outputs.screenshot }}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
project-name:
5+
description: 'Name of the application to build (e.g. qTox)'
6+
required: true
7+
type: string
8+
artifact-source:
9+
description: 'Artifact produced by the command (e.g. qTox.AppImage)'
10+
required: true
11+
type: string
12+
artifact:
13+
description: 'File name format for the artifact (e.g. qTox-$VERSION.AppImage)'
14+
required: true
15+
type: string
16+
build:
17+
description: 'Name of the build (e.g. appimage, flatpak, macos)'
18+
required: true
19+
type: string
20+
run:
21+
description: 'Command to run to build the artifact'
22+
required: true
23+
type: string
24+
25+
jobs:
26+
build:
27+
name: Build
28+
runs-on: ubuntu-24.04
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Run build
35+
run: ${{ inputs.run }}
36+
- name: Generate sha256 checksum
37+
run: sha256sum ${{ inputs.artifact-source }} >${{ inputs.artifact-source }}.sha256
38+
39+
- name: Upload artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: ${{ inputs.project-name }}-${{ github.sha }}-${{ inputs.build }}
43+
path: |
44+
${{ inputs.artifact-source }}
45+
${{ inputs.artifact-source }}.sha256
46+
if-no-files-found: error
47+
- name: Compute release file name
48+
if: contains(github.ref, 'refs/tags/v')
49+
id: release-version
50+
run: |
51+
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
52+
echo "artifact=${{ inputs.artifact }}" >>$GITHUB_OUTPUT
53+
- name: Rename artifact for release upload
54+
if: contains(github.ref, 'refs/tags/v')
55+
run: |
56+
cp "${{ inputs.artifact-source }}" "${{ steps.release-version.outputs.artifact }}"
57+
cp "${{ inputs.artifact-source }}.sha256" "${{ steps.release-version.outputs.artifact }}.sha256"
58+
- name: Upload to versioned release
59+
if: contains(github.ref, 'refs/tags/v')
60+
uses: ncipollo/release-action@v1
61+
with:
62+
allowUpdates: true
63+
draft: true
64+
artifacts: "${{ steps.release-version.outputs.artifact }},${{ steps.release-version.outputs.artifact }}.sha256"
65+
- name: Compute nightly file name
66+
id: nightly-version
67+
run: |
68+
VERSION="nightly"
69+
echo "artifact=${{ inputs.artifact }}" >>$GITHUB_OUTPUT
70+
- name: Rename artifact for nightly upload
71+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
72+
run: |
73+
cp "${{ inputs.artifact-source }}" "${{ steps.nightly-version.outputs.artifact }}"
74+
cp "${{ inputs.artifact-source }}.sha256" "${{ steps.nightly-version.outputs.artifact }}.sha256"
75+
- name: Upload to nightly release
76+
uses: ncipollo/release-action@v1
77+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
78+
with:
79+
allowUpdates: true
80+
tag: nightly
81+
omitBodyDuringUpdate: true
82+
omitNameDuringUpdate: true
83+
prerelease: true
84+
replacesArtifacts: true
85+
artifacts: "${{ steps.nightly-version.outputs.artifact }},${{ steps.nightly-version.outputs.artifact }}.sha256"

0 commit comments

Comments
 (0)