-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
actions: Add GitHub Actions pipeline for building and releasing
- Loading branch information
Showing
1 changed file
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
name: Build and Release DeckTX | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ '*' ] | ||
pull_request: | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-windows: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up CMake | ||
uses: lukka/[email protected] | ||
|
||
- name: Set reusable strings | ||
id: strings | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$env:GITHUB_ENV" | ||
echo "install-dir=${{ github.workspace }}/install" >> "$env:GITHUB_ENV" | ||
- name: Configure CMake | ||
run: cmake -B ${{ env.build-output-dir }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.install-dir }} -S ${{ github.workspace }} | ||
|
||
- name: Build | ||
run: cmake --build ${{ env.build-output-dir }} --config Release --target install | ||
|
||
- name: Package build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: DeckTX-Windows | ||
path: ${{ env.install-dir }} | ||
|
||
build-linux: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up Flatpak | ||
run: | | ||
sudo apt update | ||
sudo apt install -y flatpak flatpak-builder | ||
- name: Add Flathub Remote | ||
run: | | ||
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | ||
- name: Set reusable strings | ||
id: strings | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_ENV" | ||
echo "install-dir=${{ github.workspace }}/install" >> "$GITHUB_ENV" | ||
echo "artifact-name=decktx.flatpak" >> "$GITHUB_ENV" | ||
echo "repo-url=${{ github.repository }}" >> "$GITHUB_ENV" | ||
- name: Generate flatpak manifest | ||
run: | | ||
cat > $GITHUB_WORKSPACE/flatpak.json <<EOL | ||
{ | ||
"id": "com.pixelyion.DeckTX", | ||
"runtime": "org.freedesktop.Platform", | ||
"runtime-version": "23.08", | ||
"sdk": "org.freedesktop.Sdk", | ||
"command": "DeckTX", | ||
"modules": [ | ||
{ | ||
"name": "DeckTX", | ||
"buildsystem": "cmake", | ||
"config-opts": [ | ||
"-DCMAKE_BUILD_TYPE=Release" | ||
], | ||
"sources": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/${{ env.repo-url }}.git", | ||
"commit": "${GITHUB_SHA}", | ||
"submodules": true | ||
} | ||
] | ||
} | ||
], | ||
"finish-args": [ | ||
"--share=network", | ||
"--share=ipc", | ||
"--device=dri", | ||
"--socket=x11", | ||
"--socket=wayland", | ||
"--env=DISPLAY", | ||
"--env=XDG_RUNTIME_DIR", | ||
"--device=all", | ||
"--env=LD_LIBRARY_PATH=/app/lib:/app/lib64:/usr/lib:/usr/lib64", | ||
"--extension=org.freedesktop.Platform.Vulkan", | ||
"--env=VK_ICD_FILENAMES=/usr/share/vulkan/icd.d:/app/share/vulkan/icd.d" | ||
] | ||
} | ||
EOL | ||
- name: Build Flatpak | ||
run: | | ||
mkdir -p ${{ env.build-output-dir }}/flatpak-decktx | ||
sudo flatpak-builder --install-deps-from=flathub --force-clean --repo=repo ${{ env.build-output-dir }}/flatpak-decktx $GITHUB_WORKSPACE/flatpak.json | ||
flatpak build-bundle repo ${{ env.github.workspace }}/decktx.flatpak com.pixelyion.DeckTX | ||
- name: Package build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: DeckTX-Linux | ||
path: ${{ env.github.workspace }}/decktx.flatpak | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: [build-windows, build-linux] | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download Windows build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: DeckTX-Windows | ||
path: ${{ github.workspace }} | ||
|
||
- name: Download Linux build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: DeckTX-Linux | ||
path: ${{ github.workspace }} | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
Automatic release of DeckTX for tag ${{ github.ref }}. | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset (Windows) | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ github.workspace }}/install | ||
asset_name: decktx-windows.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Release Asset (Linux) | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ github.workspace }}/decktx.flatpak | ||
asset_name: decktx-linux.flatpak | ||
asset_content_type: application/vnd.flatpak |