name: Release on: workflow_dispatch: inputs: title: type: string description: 'Title' required: true default: 'v0.00.0 R0' # pre-release is default anymore ! # is_pre_release: # type: boolean # description: 'Set as a pre-release' # required: true # default: true style: type: integer description: '1: master only, 2: extended only, 3: both master&extended, 4: only selected branch' required: true default: 3 jobs: build-and-release: runs-on: ubuntu-latest permissions: write-all steps: - name: Create proper environment for multiple apk output run: | mkdir -p "${{ github.workspace }}/output" if [[ "${{ inputs.style }}" -eq "1" ]]; then mkdir -p "${{ github.workspace }}/master" elif [[ "${{ inputs.style }}" -eq "2" ]]; then mkdir -p "${{ github.workspace }}/extended" elif [[ "${{ inputs.style }}" -eq "3" ]]; then # mkdir -p "${{ github.workspace }}/{master,extended}" # REVIEW not working, why? mkdir -p "${{ github.workspace }}/master" mkdir -p "${{ github.workspace }}/extended" else mkdir -p "${{ github.workspace }}/current" fi ls -la - name: Checkout all selected branches env: BRANCH: ${{ github.ref_name }} run: | if [[ "${{ inputs.style }}" -eq "1" ]]; then cd "${{ github.workspace }}/master" git clone --no-checkout https://github.com/MaintainTeam/LastPipeBender.git . git config core.symlinks false git checkout --progress --force "master" elif [[ "${{ inputs.style }}" -eq "2" ]]; then cd "${{ github.workspace }}/extended" git clone --no-checkout https://github.com/MaintainTeam/LastPipeBender.git . git config core.symlinks false git checkout --progress --force "extended" elif [[ "${{ inputs.style }}" -eq "3" ]]; then cd "${{ github.workspace }}/master" git clone --no-checkout https://github.com/MaintainTeam/LastPipeBender.git . git config core.symlinks false git checkout --progress --force "master" cd "${{ github.workspace }}/extended" git clone --no-checkout https://github.com/MaintainTeam/LastPipeBender.git . git config core.symlinks false git checkout --progress --force "extended" else cd "${{ github.workspace }}/current" git clone --no-checkout https://github.com/MaintainTeam/LastPipeBender.git . git config core.symlinks false git checkout --progress --force "$BRANCH" fi - name: Set up JDK uses: actions/setup-java@v4 with: java-version: 21 distribution: "temurin" cache: 'gradle' - name: Build release APK run: | if [[ "${{ inputs.style }}" -eq "1" ]]; then cd "${{ github.workspace }}/master" echo "::notice::building master" ./gradlew assembleRelease mv "${{ github.workspace }}/master/app/build/outputs/apk/release/app-release-unsigned.apk" "${{ github.workspace }}/output/master.apk" cp "./.github/changelog.md" "${{ github.workspace }}/output/" elif [[ "${{ inputs.style }}" -eq "2" ]]; then cd "${{ github.workspace }}/extended/" echo "::notice::building extended" ./gradlew assembleRelease mv "${{ github.workspace }}/extended/app/build/outputs/apk/release/app-release-unsigned.apk" "${{ github.workspace }}/output/extended.apk" cp "./.github/changelog.md" "${{ github.workspace }}/output/" elif [[ "${{ inputs.style }}" -eq "3" ]]; then echo "::notice::both master and extended are going to build" cd "${{ github.workspace }}/master" echo "::notice::building master" ./gradlew assembleRelease mv "${{ github.workspace }}/master/app/build/outputs/apk/release/app-release-unsigned.apk" "${{ github.workspace }}/output/master.apk" cp "./.github/changelog.md" "${{ github.workspace }}/output/" cd "${{ github.workspace }}/extended" echo "::notice::building extended" ./gradlew assembleRelease mv "${{ github.workspace }}/extended/app/build/outputs/apk/release/app-release-unsigned.apk" "${{ github.workspace }}/output/extended.apk" else cd "${{ github.workspace }}/current" echo "::notice::building current" ./gradlew assembleRelease mv "${{ github.workspace }}/current/app/build/outputs/apk/release/app-release-unsigned.apk" "${{ github.workspace }}/output/current.apk" cp "./.github/changelog.md" "${{ github.workspace }}/output/" fi - name: Sign APK env: KEYSTORE: ${{ secrets.KEYSTORE }} SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} run: | cd "${{ github.workspace }}/output/" echo "${KEYSTORE}" | base64 -d > apksign.keystore if [[ "${{ inputs.style }}" -eq "1" ]]; then version=$( grep "versionName" "${{ github.workspace }}/master/app/build.gradle" | awk -F'"' '{print $2}' ) ${ANDROID_HOME}/build-tools/34.0.0/apksigner sign --ks apksign.keystore --ks-pass env:SIGNING_STORE_PASSWORD "./master.apk" mv "master.apk" "pipebender_v${version}.apk" elif [[ "${{ inputs.style }}" -eq "2" ]]; then version=$( grep "versionName" "${{ github.workspace }}/extended/app/build.gradle" | awk -F'"' '{print $2}' ) ${ANDROID_HOME}/build-tools/34.0.0/apksigner sign --ks apksign.keystore --ks-pass env:SIGNING_STORE_PASSWORD "./extended.apk" mv "extended.apk" "pipebender_extended_v${version}.apk" elif [[ "${{ inputs.style }}" -eq "3" ]]; then version=$( grep "versionName" "${{ github.workspace }}/master/app/build.gradle" | awk -F'"' '{print $2}' ) # Use version of master app while both released ! ${ANDROID_HOME}/build-tools/34.0.0/apksigner sign --ks apksign.keystore --ks-pass env:SIGNING_STORE_PASSWORD "./master.apk" mv "master.apk" "pipebender_v${version}.apk" ${ANDROID_HOME}/build-tools/34.0.0/apksigner sign --ks apksign.keystore --ks-pass env:SIGNING_STORE_PASSWORD "./extended.apk" mv "extended.apk" "pipebender_extended_v${version}.apk" else mkdir "${{ github.workspace }}/current" version=$( grep "versionName" "${{ github.workspace }}/current/app/build.gradle" | awk -F'"' '{print $2}' ) ${ANDROID_HOME}/build-tools/34.0.0/apksigner sign --ks apksign.keystore --ks-pass env:SIGNING_STORE_PASSWORD "./current.apk" mv "current.apk" "pipebender_v${version}.apk" fi echo ${version} > version.num ls -la - name: Generate checksum run: | cd "${{ github.workspace }}/output/" find . -name '*.apk' -type f -exec sha256sum {} \; > checksums.txt echo "::notice::$(echo $(cat ./checksums.txt))" ls -la - name: Create release and upload run: | gh auth login --with-token <<<"${{ secrets.GITHUB_TOKEN }}" cd "${{ github.workspace }}/output/" version=$(cat version.num) echo $version gh release create "v${version}" --title "${{ inputs.title }}" --notes-file "./changelog.md" --prerelease="true" --repo MaintainTeam/LastPipeBender gh release upload "v${version}" $(echo $(find . -name '*.apk' -type f -exec basename \{} \;) checksums.txt) --repo MaintainTeam/LastPipeBender - name: Archive reports for job uses: actions/upload-artifact@v4 with: name: reports path: '*/build/reports' if: ${{ always() }}