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'
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"
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'
0 commit comments