Allow building release builds and…

…trigger GH release using tags
This commit is contained in:
txtsd 2022-02-12 09:09:36 +05:30
parent 2cd837896d
commit 8596753a63
No known key found for this signature in database
GPG Key ID: 000F85679D4B6B53
2 changed files with 115 additions and 13 deletions

View File

@ -1,7 +1,12 @@
name: build_portable
name: Build
on:
[push, pull_request, workflow_dispatch]
workflow_call:
inputs:
build_type:
description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel)
type: string
default: Debug
jobs:
build:
@ -59,6 +64,12 @@ jobs:
copy "${{ github.workspace }}\Qt\Tools\OpenSSL\Win_x86\bin\libssl-1_1.dll" "${{ github.workspace }}\${{ env.INSTALL_DIR }}\"
copy "${{ github.workspace }}\Qt\Tools\OpenSSL\Win_x86\bin\libcrypto-1_1.dll" "${{ github.workspace }}\${{ env.INSTALL_DIR }}\"
- name: Set short version
shell: bash
run: |
ver_short=`git rev-parse --short HEAD`
echo "VERSION=$ver_short" >> $GITHUB_ENV
- name: Install OpenJDK
uses: AdoptOpenJDK/install-jdk@v1
with:
@ -99,12 +110,12 @@ jobs:
- name: Configure CMake
if: runner.os != 'Linux'
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=Debug -G Ninja
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -G Ninja
- name: Configure CMake on Linux
if: runner.os == 'Linux'
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DLauncher_LAYOUT=lin-system -G Ninja
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DLauncher_LAYOUT=lin-system -G Ninja
- name: Build
run: |
@ -124,7 +135,7 @@ jobs:
if: runner.os == 'Linux'
shell: bash
run: |
export OUTPUT="PolyMC-${{ github.sha }}-x86_64.AppImage"
export OUTPUT="PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage"
chmod +x linuxdeploy-*.AppImage
@ -145,13 +156,13 @@ jobs:
- name: Run windeployqt
if: runner.os == 'Windows'
run: |
windeployqt --no-translations "${{ env.INSTALL_DIR }}/polymc.exe"
windeployqt --no-translations --no-system-d3d-compiler --no-opengl-sw "${{ env.INSTALL_DIR }}/polymc.exe"
- name: Run macdeployqt
if: runner.os == 'macOS'
run: |
cd ${{ env.INSTALL_DIR }}
macdeployqt "PolyMC.app" -executable="PolyMC.app/Contents/MacOS/polymc" -always-overwrite -use-debug-libs
macdeployqt "PolyMC.app" -executable="PolyMC.app/Contents/MacOS/polymc" -always-overwrite
- name: chmod binary on macOS
if: runner.os == 'macOS'
@ -162,25 +173,25 @@ jobs:
if: runner.os == 'macOS'
run: |
cd ${{ env.INSTALL_DIR }}
tar -czf ../polymc.tar.gz *
tar -czf ../PolyMC.tar.gz *
- name: Upload AppImage for Linux
if: runner.os == 'Linux'
uses: actions/upload-artifact@v2
with:
name: PolyMC-${{ github.sha }}-x86_64.AppImage
path: PolyMC-${{ github.sha }}-x86_64.AppImage
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
path: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
- name: Upload package for Windows
if: runner.os == 'Windows'
uses: actions/upload-artifact@v2
with:
name: polymc-${{ runner.os }}-${{ github.sha }}-portable
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: ${{ env.INSTALL_DIR }}/**
- name: Upload package for macOS
if: runner.os == 'macOS'
uses: actions/upload-artifact@v2
with:
name: polymc-${{ runner.os }}-${{ github.sha }}-portable
path: polymc.tar.gz
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: PolyMC.tar.gz

91
.github/workflows/trigger_builds.yml vendored Normal file
View File

@ -0,0 +1,91 @@
name: Build Application
on:
[push, pull_request, workflow_dispatch]
jobs:
build_debug:
name: Build Debug
uses: ./.github/workflows/build.yml
with:
build_type: Debug
build_release:
name: Build Release
uses: ./.github/workflows/build.yml
with:
build_type: Release
create_release:
if: startsWith(github.ref, 'refs/tags/')
needs: build_release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: PolyMC ${{ github.ref }}
draft: true
prerelease: false
upload_release:
needs: create_release
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Grab and store version
run: |
tag_name=$(echo ${{ github.ref }} | grep -oE "[^/]+$")
echo "VERSION=$tag_name" >> $GITHUB_ENV
- name: Package artifacts properly
run: |
rm -rf *Debug*
mv PolyMC-*.AppImage/PolyMC-*.AppImage PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
mv PolyMC-Windows* PolyMC-Windows-${{ env.VERSION }}
mv PolyMC-macOS*/PolyMC.tar.gz PolyMC-macOS-${{ env.VERSION }}.tar.gz
cd PolyMC-Windows-${{ env.VERSION }}
zip -r -9 ../PolyMC-Windows-${{ env.VERSION }}.zip *
cd ..
- name: Upload Linux AppImage asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
asset_path: PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
asset_content_type: application/x-executable
- name: Upload Windows asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: PolyMC-Windows-${{ env.VERSION }}.zip
asset_path: PolyMC-Windows-${{ env.VERSION }}.zip
asset_content_type: application/zip
- name: Upload macOS asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: PolyMC-macOS-${{ env.VERSION }}.tar.gz
asset_path: PolyMC-macOS-${{ env.VERSION }}.tar.gz
asset_content_type: application/gzip