GH Release Packages #83
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: GH Release Packages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to release' | |
| required: true | |
| arch: | |
| type: choice | |
| description: 'Architecture to build' | |
| required: true | |
| default: all | |
| options: | |
| - all | |
| - x86_64 | |
| - arm64 | |
| release-deb: | |
| type: boolean | |
| description: 'Build DEB package' | |
| required: true | |
| default: true | |
| release-rpm: | |
| type: boolean | |
| description: 'Build RPM package' | |
| required: true | |
| default: true | |
| release-pkg: | |
| type: boolean | |
| description: 'Build PKG package' | |
| required: true | |
| default: true | |
| release-binary: | |
| type: boolean | |
| description: 'Build binary package' | |
| required: true | |
| default: true | |
| gh-release: | |
| type: boolean | |
| description: 'Update GitHub release' | |
| required: true | |
| default: true | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check tag exists | |
| uses: mukunku/tag-exists-action@v1.6.0 | |
| id: check-tag | |
| with: | |
| tag: ${{ inputs.tag }} | |
| - name: Exit if tag does not exist | |
| run: | | |
| if [[ "${{ steps.check-tag.outputs.exists }}" == "false" ]]; then | |
| echo "Tag ${{ inputs.tag }} does not exist" | |
| exit 1 | |
| fi | |
| setup-matrix: | |
| needs: | |
| - check | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.result }} | |
| steps: | |
| - name: Set up matrix | |
| id: set-matrix | |
| uses: actions/github-script@v7 | |
| with: | |
| result-encoding: string | |
| script: | | |
| const inputs = ${{ toJson(inputs) }} | |
| const { arch } = inputs | |
| const osMap = { | |
| "all": ["ubuntu-latest", "ubuntu-24.04-arm"], | |
| "x86_64": ["ubuntu-latest"], | |
| "arm64": ["ubuntu-24.04-arm"] | |
| } | |
| const package = Object.entries(inputs) | |
| .filter(([key, value]) => key.startsWith('release-') && value) | |
| .map(([key, value]) => key.replace('release-', '')) | |
| return JSON.stringify({ | |
| os: osMap[arch], | |
| package, | |
| }) | |
| build: | |
| needs: | |
| - setup-matrix | |
| strategy: | |
| matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Prepare workspace | |
| run: rm -rf build-${{ matrix.package }} && mkdir -p build-${{ matrix.package }} | |
| - name: Download ${{ inputs.tag }} source code | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| gh -R yuezk/GlobalProtect-openconnect \ | |
| release download ${{ inputs.tag }} \ | |
| --pattern '*[^offline].tar.gz' \ | |
| --dir build-${{ matrix.package }} | |
| - name: Docker Login | |
| run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | |
| - name: Build ${{ matrix.package }} package in Docker | |
| # LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros | |
| run: | | |
| docker run --pull=always --rm \ | |
| -v $(pwd)/build-${{ matrix.package }}:/workspace \ | |
| -e COREPACK_INTEGRITY_KEYS=0 \ | |
| -e LIBXML2_STATIC=1 \ | |
| -e INCLUDE_GUI=1 \ | |
| yuezk/gpdev:${{ matrix.package }}-builder-tauri2 | |
| - name: Install ${{ matrix.package }} package in Docker | |
| run: | | |
| docker run --pull=always --rm \ | |
| -e COREPACK_INTEGRITY_KEYS=0 \ | |
| -v $(pwd)/build-${{ matrix.package }}:/workspace \ | |
| yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \ | |
| bash install.sh | |
| - name: Upload ${{ matrix.package }} package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: artifact-${{ matrix.os }}-${{ matrix.package }} | |
| if-no-files-found: error | |
| path: | | |
| build-${{ matrix.package }}/artifacts/* | |
| gh-release: | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| if: ${{ inputs.gh-release }} | |
| steps: | |
| - name: Prepare workspace | |
| run: rm -rf gh-release && mkdir gh-release | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: gh-release | |
| - name: Update release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| prerelease: ${{ contains(github.ref, 'snapshot') }} | |
| fail_on_unmatched_files: true | |
| tag_name: ${{ inputs.tag }} | |
| files: | | |
| gh-release/artifact-*/* | |