Skip to content

Commit ba24249

Browse files
committed
feat: Make project-name optional, infer from cmake.
It's still there as an override, but we'll now try to infer it from the `project()` call in CMakeLists.txt.
1 parent 829df80 commit ba24249

7 files changed

Lines changed: 139 additions & 63 deletions

File tree

.github/workflows/deploy-android.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
inputs:
44
project-name:
55
description: 'Name of the application to build (e.g. qTox)'
6-
required: true
6+
required: false
77
type: string
88
cmake-args:
99
description: 'Arguments to pass to CMake'
@@ -34,9 +34,15 @@ jobs:
3434
- build-type: ${{ (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') || contains(github.ref, 'refs/tags/v')) && 'Debug' }}
3535
- version: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'packaging') && '6.8.1' }}
3636
steps:
37+
- name: Install prerequisites
38+
run: sudo apt-get install -y --no-install-recommends pcregrep
3739
- name: Compute values for remaining steps
3840
id: computed
3941
run: |
42+
PROJECT_NAME="${{ inputs.project-name }}"
43+
if [ -z "$PROJECT_NAME" ]; then
44+
PROJECT_NAME="$(pcregrep -M -o1 'project\(\s*(\S+)' CMakeLists.txt)"
45+
fi
4046
ARTIFACT_TYPE="$(echo '${{ matrix.build-type }}' | tr '[:upper:]' '[:lower:]')"
4147
echo "artifact_type=$ARTIFACT_TYPE" >>$GITHUB_OUTPUT
4248
if [ "${{ matrix.version }}" == "6.2.4" ]; then
@@ -47,12 +53,17 @@ jobs:
4753
echo "built_apk=_build/android-build/build/outputs/apk/$ARTIFACT_TYPE/android-build-$ARTIFACT_TYPE-signed.apk" >>$GITHUB_OUTPUT
4854
fi
4955
echo "suffix=$SUFFIX" >>$GITHUB_OUTPUT
50-
echo "nightly_apk=${{ inputs.project-name }}-nightly-${{ matrix.arch }}-$ARTIFACT_TYPE$SUFFIX.apk" >>$GITHUB_OUTPUT
56+
echo "nightly_apk=$PROJECT_NAME-nightly-${{ matrix.arch }}-$ARTIFACT_TYPE$SUFFIX.apk" >>$GITHUB_OUTPUT
5157
echo "docker_image=android_builder.${{ matrix.arch }}.${ARTIFACT_TYPE}_${{ matrix.version }}" >>$GITHUB_OUTPUT
5258
- uses: actions/checkout@v4
5359
with:
5460
fetch-depth: 0
5561
submodules: true
62+
- name: Checkout ci-tools
63+
uses: actions/checkout@v4
64+
with:
65+
repository: TokTok/ci-tools
66+
path: ci-tools
5667
- name: Fetch build scripts
5768
run: |
5869
git clone --depth=1 https://github.com/TokTok/dockerfiles "third_party/dockerfiles"
@@ -62,7 +73,7 @@ jobs:
6273
run: |
6374
ARTIFACT="${{ steps.computed.outputs.built_apk }}"
6475
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
65-
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-android-${{ matrix.arch }}-${{ matrix.build-type }}-${{ matrix.version }}" >>$GITHUB_OUTPUT
76+
echo "artifact-ref=${{ steps.computed.outputs.project-name }}-${{ github.sha }}-android-${{ matrix.arch }}-${{ matrix.build-type }}-${{ matrix.version }}" >>$GITHUB_OUTPUT
6677
- name: Cache compiler output
6778
uses: actions/cache@v4
6879
with:
@@ -79,25 +90,28 @@ jobs:
7990
--build-type ${{ matrix.build-type }}
8091
--
8192
${{ inputs.cmake-args }}
93+
- name: Generate sha256 checksum
94+
id: sha256
95+
run: ci-tools/tools/artifact_sha256.py
96+
"${{ steps.computed.outputs.project-name }}"
97+
${{ steps.computed.outputs.built_apk }}
8298
- name: Upload artifact
8399
uses: actions/upload-artifact@v4
84100
with:
85101
name: ${{ steps.artifact.outputs.artifact-ref }}
86-
path: |
87-
${{ steps.artifact.outputs.artifact }}
88-
${{ steps.artifact.outputs.artifact }}.sha256
102+
path: ${{ steps.sha256.outputs.artifacts }}
89103
if-no-files-found: error
90104
- name: Get tag name for Android release file name
91105
if: contains(github.ref, 'refs/tags/v')
92106
id: get_version
93107
run: |
94108
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
95-
echo "release_apk=${{ inputs.project-name }}-$VERSION-${{ matrix.arch }}-${{ steps.computed.outputs.artifact_type }}${{ steps.computed.outputs.suffix }}.apk" >>$GITHUB_OUTPUT
109+
echo "release_apk=${{ steps.computed.outputs.project-name }}-$VERSION-${{ matrix.arch }}-${{ steps.computed.outputs.artifact_type }}${{ steps.computed.outputs.suffix }}.apk" >>$GITHUB_OUTPUT
96110
- name: Rename Android APK for release upload
97111
if: contains(github.ref, 'refs/tags/v')
98112
run: |
99-
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.get_version.outputs.release_apk }}"
100-
sha256sum "${{ steps.get_version.outputs.release_apk }}" > "${{ steps.get_version.outputs.release_apk }}.sha256"
113+
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.get_version.outputs.release_apk }}"
114+
cp "${{ steps.computed.outputs.built_apk }}.sha256" "${{ steps.get_version.outputs.release_apk }}.sha256"
101115
- name: Upload to versioned release
102116
if: inputs.production && contains(github.ref, 'refs/tags/v')
103117
uses: ncipollo/release-action@v1
@@ -107,10 +121,9 @@ jobs:
107121
token: ${{ secrets.GITHUB_TOKEN }}
108122
artifacts: "${{ steps.get_version.outputs.release_apk }},${{ steps.get_version.outputs.release_apk }}.sha256"
109123
- name: Rename Android APK for nightly upload
110-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
111124
run: |
112-
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.computed.outputs.nightly_apk }}"
113-
sha256sum "${{ steps.computed.outputs.nightly_apk }}" > "${{ steps.computed.outputs.nightly_apk }}.sha256"
125+
cp "${{ steps.computed.outputs.built_apk }}" "${{ steps.computed.outputs.nightly_apk }}"
126+
cp "${{ steps.computed.outputs.built_apk }}.sha256" "${{ steps.computed.outputs.nightly_apk }}.sha256"
114127
- name: Upload to nightly release
115128
uses: ncipollo/release-action@v1
116129
if: github.event_name == 'push' && github.ref == 'refs/heads/master'

.github/workflows/deploy-appimage.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
inputs:
44
project-name:
55
description: 'Name of the application to build (e.g. qTox)'
6-
required: true
6+
required: false
77
type: string
88
cmake-args:
99
description: 'Arguments to pass to CMake'
@@ -37,6 +37,8 @@ jobs:
3737
arch: [x86_64]
3838
runs-on: ubuntu-24.04
3939
steps:
40+
- name: Install prerequisites
41+
run: sudo apt-get install -y --no-install-recommends pcregrep
4042
- uses: actions/checkout@v4
4143
with:
4244
fetch-depth: 0
@@ -48,9 +50,15 @@ jobs:
4850
- name: Determine artifact file name
4951
id: artifact
5052
run: |
51-
ARTIFACT="${{ inputs.project-name }}-$(git rev-parse --short HEAD | head -c7)-${{ matrix.arch }}.AppImage"
53+
sudo apt-get install -y --no-install-recommends pcregrep
54+
PROJECT_NAME="${{ inputs.project-name }}"
55+
if [ -z "$PROJECT_NAME" ]; then
56+
PROJECT_NAME="$(pcregrep -M -o1 'project\(\s*(\S+)' CMakeLists.txt)"
57+
fi
58+
ARTIFACT="$PROJECT_NAME-$(git rev-parse --short HEAD | head -c7)-${{ matrix.arch }}.AppImage"
5259
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
53-
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-appimage-${{ matrix.arch }}" >>$GITHUB_OUTPUT
60+
echo "artifact-ref=$PROJECT_NAME-${{ github.sha }}-appimage-${{ matrix.arch }}" >>$GITHUB_OUTPUT
61+
echo "project-name=$PROJECT_NAME" >>$GITHUB_OUTPUT
5462
- name: Cache compiler output
5563
uses: actions/cache@v4
5664
with:
@@ -67,7 +75,7 @@ jobs:
6775
platform/appimage/build.sh
6876
--arch ${{ matrix.arch }}
6977
--src-dir /qtox
70-
--project-name ${{ inputs.project-name }}
78+
--project-name ${{ steps.artifact.outputs.project-name }}
7179
--
7280
${{ inputs.cmake-args }}
7381

@@ -85,7 +93,7 @@ jobs:
8593
id: get_version
8694
run: |
8795
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
88-
echo "release_artifact=${{ inputs.project-name }}-$VERSION-${{ matrix.arch }}.AppImage" >>$GITHUB_OUTPUT
96+
echo "release_artifact=${{ steps.artifact.outputs.project-name }}-$VERSION-${{ matrix.arch }}.AppImage" >>$GITHUB_OUTPUT
8997
- name: Rename artifact for release upload
9098
if: contains(github.ref, 'refs/tags/v')
9199
run: |
@@ -102,9 +110,9 @@ jobs:
102110
- name: Rename artifact for nightly upload
103111
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
104112
run: |
105-
cp "${{ steps.artifact.outputs.artifact }}" "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage"
106-
cp "${{ steps.artifact.outputs.artifact }}.sha256" "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.sha256"
107-
cp "${{ steps.artifact.outputs.artifact }}.zsync" "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.zsync"
113+
cp "${{ steps.artifact.outputs.artifact }}" "${{ steps.artifact.outputs.project-name }}-nightly-${{ matrix.arch }}.AppImage"
114+
cp "${{ steps.artifact.outputs.artifact }}.sha256" "${{ steps.artifact.outputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.sha256"
115+
cp "${{ steps.artifact.outputs.artifact }}.zsync" "${{ steps.artifact.outputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.zsync"
108116
- name: Upload to nightly release
109117
uses: ncipollo/release-action@v1
110118
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -115,7 +123,7 @@ jobs:
115123
omitNameDuringUpdate: true
116124
prerelease: true
117125
replacesArtifacts: true
118-
artifacts: "${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage,${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.sha256,${{ inputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.zsync"
126+
artifacts: "${{ steps.artifact.outputs.project-name }}-nightly-${{ matrix.arch }}.AppImage,${{ steps.artifact.outputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.sha256,${{ steps.artifact.outputs.project-name }}-nightly-${{ matrix.arch }}.AppImage.zsync"
119127

120128
test:
121129
name: Test on Ubuntu
@@ -134,9 +142,13 @@ jobs:
134142
- name: Determine artifact file name
135143
id: artifact
136144
run: |
137-
ARTIFACT="${{ inputs.project-name }}-$(git rev-parse --short HEAD | head -c7)-${{ matrix.arch }}.AppImage"
145+
PROJECT_NAME="${{ inputs.project-name }}"
146+
if [ -z "$PROJECT_NAME" ]; then
147+
PROJECT_NAME="$(pcregrep -M -o1 'project\(\s*(\S+)' CMakeLists.txt)"
148+
fi
149+
ARTIFACT="$PROJECT_NAME-$(git rev-parse --short HEAD | head -c7)-${{ matrix.arch }}.AppImage"
138150
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
139-
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-appimage-${{ matrix.arch }}" >>$GITHUB_OUTPUT
151+
echo "artifact-ref=$PROJECT_NAME-${{ github.sha }}-appimage-${{ matrix.arch }}" >>$GITHUB_OUTPUT
140152
- name: Download artifact from build step
141153
uses: actions/download-artifact@v4
142154
with:
@@ -149,7 +161,7 @@ jobs:
149161
echo "screenshot=$QTOX_SCREENSHOT" >>$GITHUB_OUTPUT
150162
env:
151163
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152-
QTOX_SCREENSHOT: ${{ inputs.screenshot && format('{0}-AppImage-{1}.png', inputs.project-name, matrix.arch) }}
164+
QTOX_SCREENSHOT: ${{ inputs.screenshot && format('{0}-AppImage-{1}.png', steps.artifact.outputs.project-name, matrix.arch) }}
153165
- name: Upload screenshot artifact
154166
if: inputs.screenshot
155167
uses: actions/upload-artifact@v4

.github/workflows/deploy-artifact.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
inputs:
44
project-name:
55
description: 'Name of the application to build (e.g. qTox)'
6-
required: true
6+
required: false
77
type: string
88
artifact-source:
99
description: 'Artifact produced by the command (e.g. qTox.AppImage)'
@@ -27,27 +27,32 @@ jobs:
2727
name: Build
2828
runs-on: ubuntu-24.04
2929
steps:
30+
- name: Install prerequisites
31+
run: sudo apt-get install -y --no-install-recommends pcregrep
3032
- uses: actions/checkout@v4
3133
with:
3234
fetch-depth: 0
3335
submodules: true
3436
- name: Checkout ci-tools
3537
uses: actions/checkout@v4
3638
with:
37-
repository: TokTok/ci-tools
39+
repository: iphydf/ci-tools
40+
ref: infer-project-name
3841
path: ci-tools
3942
submodules: true
4043

4144
- name: Run build
4245
run: ${{ inputs.run }}
46+
4347
- name: Generate sha256 checksum
4448
id: sha256
45-
run: ci-tools/tools/artifact_sha256.py ${{ inputs.artifact-source }}
46-
49+
run: ci-tools/tools/artifact_sha256.py
50+
"${{ inputs.project-name }}"
51+
${{ inputs.artifact-source }}
4752
- name: Upload artifact
4853
uses: actions/upload-artifact@v4
4954
with:
50-
name: ${{ inputs.project-name }}-${{ github.sha }}-${{ inputs.build }}
55+
name: ${{ steps.sha256.outputs.project-name }}-${{ github.sha }}-${{ inputs.build }}
5156
path: ${{ steps.sha256.outputs.artifacts }}
5257
if-no-files-found: error
5358
- name: Rename artifact for release upload

.github/workflows/deploy-flatpak.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
inputs:
44
project-name:
55
description: 'Name of the application to build (e.g. qTox)'
6-
required: true
6+
required: false
77
type: string
88
org-name:
99
description: 'Reverse domain name of the organization to build (e.g. chat.tox)'
@@ -51,10 +51,15 @@ jobs:
5151
- name: Determine artifact file name
5252
id: artifact
5353
run: |
54-
ARTIFACT="${{ inputs.project-name }}.flatpak"
54+
PROJECT_NAME="${{ inputs.project-name }}"
55+
if [ -z "$PROJECT_NAME" ]; then
56+
PROJECT_NAME="$(pcregrep -M -o1 'project\(\s*(\S+)' CMakeLists.txt)"
57+
fi
58+
ARTIFACT="$PROJECT_NAME.flatpak"
5559
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
56-
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-flatpak-${{ matrix.arch }}" >>$GITHUB_OUTPUT
57-
echo "binary-name=$(echo ${{ inputs.project-name }} | tr '[:upper:]' '[:lower:]')" >>$GITHUB_OUTPUT
60+
echo "artifact-ref=$PROJECT_NAME-${{ github.sha }}-flatpak-${{ matrix.arch }}" >>$GITHUB_OUTPUT
61+
echo "binary-name=$(echo "$PROJECT_NAME" | tr '[:upper:]' '[:lower:]')" >>$GITHUB_OUTPUT
62+
echo "project-name=$PROJECT_NAME" >>$GITHUB_OUTPUT
5863
- name: Cache flatpak-builder cache (except ccache)
5964
uses: actions/cache@v4
6065
with:
@@ -75,7 +80,7 @@ jobs:
7580
--rm
7681
flatpak
7782
platform/flatpak/build.sh
78-
${{ inputs.project-name }}
83+
${{ steps.artifact.outputs.project-name }}
7984
${{ inputs.org-name }}
8085

8186
- name: Upload artifact
@@ -92,7 +97,7 @@ jobs:
9297
run: |
9398
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
9499
echo "version_tag=$VERSION" >>$GITHUB_OUTPUT
95-
echo "release_artifact=${{ inputs.project-name }}-$VERSION.${{ matrix.arch }}.flatpak" >>$GITHUB_OUTPUT
100+
echo "release_artifact=${{ steps.artifact.outputs.project-name }}-$VERSION.${{ matrix.arch }}.flatpak" >>$GITHUB_OUTPUT
96101
- name: Rename artifact for release upload
97102
if: contains(github.ref, 'refs/tags/v')
98103
run: |
@@ -108,8 +113,8 @@ jobs:
108113
- name: Rename flatpak for nightly upload
109114
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
110115
run: |
111-
cp "${{ steps.artifact.outputs.artifact }}" "${{ inputs.project-name }}-nightly.flatpak"
112-
cp "${{ steps.artifact.outputs.artifact }}.sha256" "${{ inputs.project-name }}-nightly.flatpak.sha256"
116+
cp "${{ steps.artifact.outputs.artifact }}" "${{ steps.artifact.outputs.project-name }}-nightly.flatpak"
117+
cp "${{ steps.artifact.outputs.artifact }}.sha256" "${{ steps.artifact.outputs.project-name }}-nightly.flatpak.sha256"
113118
- name: Upload to nightly release
114119
uses: ncipollo/release-action@v1
115120
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -120,7 +125,7 @@ jobs:
120125
omitNameDuringUpdate: true
121126
prerelease: true
122127
replacesArtifacts: true
123-
artifacts: "${{ inputs.project-name }}-nightly.flatpak,${{ inputs.project-name }}-nightly.flatpak.sha256"
128+
artifacts: "${{ steps.artifact.outputs.project-name }}-nightly.flatpak,${{ steps.artifact.outputs.project-name }}-nightly.flatpak.sha256"
124129

125130
test:
126131
name: Test
@@ -130,6 +135,8 @@ jobs:
130135
arch: [x86_64]
131136
runs-on: ubuntu-22.04
132137
steps:
138+
- name: Install prerequisites
139+
run: sudo apt-get install -y --no-install-recommends pcregrep
133140
- uses: actions/checkout@v4
134141
with:
135142
# Fetch tags if we're not already in a tag build.
@@ -138,10 +145,15 @@ jobs:
138145
- name: Determine artifact file name
139146
id: artifact
140147
run: |
141-
ARTIFACT="${{ inputs.project-name }}.flatpak"
148+
PROJECT_NAME="${{ inputs.project-name }}"
149+
if [ -z "$PROJECT_NAME" ]; then
150+
PROJECT_NAME="$(pcregrep -M -o1 'project\(\s*(\S+)' CMakeLists.txt)"
151+
fi
152+
ARTIFACT="$PROJECT_NAME.flatpak"
142153
echo "artifact=$ARTIFACT" >>$GITHUB_OUTPUT
143-
echo "artifact-ref=${{ inputs.project-name }}-${{ github.sha }}-flatpak-${{ matrix.arch }}" >>$GITHUB_OUTPUT
144-
echo "binary-name=$(echo ${{ inputs.project-name }} | tr '[:upper:]' '[:lower:]')" >>$GITHUB_OUTPUT
154+
echo "artifact-ref=$PROJECT_NAME-${{ github.sha }}-flatpak-${{ matrix.arch }}" >>$GITHUB_OUTPUT
155+
echo "binary-name=$(echo "$PROJECT_NAME" | tr '[:upper:]' '[:lower:]')" >>$GITHUB_OUTPUT
156+
echo "project-name=$PROJECT_NAME" >>$GITHUB_OUTPUT
145157
- name: Download artifact from build step
146158
uses: actions/download-artifact@v4
147159
with:
@@ -155,7 +167,7 @@ jobs:
155167
- name: Install flatpak
156168
run: flatpak install --user -y --bundle ${{ steps.artifact.outputs.artifact }}
157169
- name: Run flatpak
158-
run: ${{ inputs.smoke-test }} flatpak run ${{ inputs.org-name }}.${{ inputs.project-name }}
170+
run: ${{ inputs.smoke-test }} flatpak run ${{ inputs.org-name }}.${{ steps.artifact.outputs.project-name }}
159171
env:
160172
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161173
QT_QPA_PLATFORM: offscreen

0 commit comments

Comments
 (0)