Skip to content

Commit

Permalink
Add GitHub Workflow for release builds (#29)
Browse files Browse the repository at this point in the history
* Add basic Docker build for Debian Bookworm.

* Starter GitHub Workflow for testing releases.

* Add CMake build presets.

* Use Bookworm "slim" image.

* Add tag filter so release workflow only runs on commits tagged with a version number.
  • Loading branch information
krazkidd authored Jun 18, 2024
1 parent e857656 commit fc295bb
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 23 deletions.
27 changes: 27 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#**/__pycache__
#**/.venv
#**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.github
#**/.project
#**/.settings
#**/.toolstarget
**/.vs
**/.vscode
#**/*.*proj.user
#**/*.dbmdl
#**/*.jfm
#**/bin
#**/charts
#**/docker-compose*
#**/compose*
**/Dockerfile*
#**/node_modules
#**/npm-debug.log
build/
CMakeUserPresets.json
LICENSE.md
README.md
52 changes: 29 additions & 23 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- main
tags:
- "v*.*.*"

workflow_dispatch:
# allows manual execution of the workflow

Expand All @@ -14,34 +17,37 @@ defaults:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Build and package
# uses: docker/build-push-action@v2
# with:
# context: .
# file: Dockerfile
# push: false
# tags: kdash-build:latest

- name: Build Docker image
run: docker build -t kdeck-build .

# NOTE: We use a bind-mount instead of a volume because the runner user
# does not have permission to access a created volume.

- name: Run build in Docker container
#run: docker run -v "$(pwd):/src" kdeck-build
run: docker run -v "build:/src/build" kdeck-build

# - name: Create tarball
# run: |
# mkdir release
# cp path/to/executable release/
# cp path/to/LICENSE release/
# tar -czvf release.tar.gz release/

# - name: Upload artifact
# uses: actions/upload-artifact@v2
# with:
# name: release-artifact
# path: release.tar.gz
run: docker run -v "${{ github.workspace }}/build:/src/build" kdeck-build

- name: Record hash
run: echo ${{ github.sha }} > release.txt

- name: Create tarball
run: |
tar -czvf "kdeck-Linux64-${{ github.ref_name }}.tar.gz" \
--directory="${{ github.workspace }}" \
release.txt \
LICENSE.md \
--directory="${{ github.workspace }}/build/bin/Linux64/Release" \
kdeck
- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: true
fail_on_unmatched_files: true
files: |
kdeck-Linux64-${{ github.ref_name }}.tar.gz
20 changes: 20 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,25 @@
}
}
}
],
"buildPresets": [
{
"name": "debug",
"displayName": "Debug",
"description": "",
"configurePreset": "debug",
"targets": [
"kdeck"
]
},
{
"name": "release",
"displayName": "Release",
"description": "",
"configurePreset": "release",
"targets": [
"kdeck"
]
}
]
}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM debian:bookworm-slim

RUN apt-get update && apt-get -y --no-install-recommends --no-install-suggests install \
build-essential \
cmake \
libcurlpp-dev \
libboost-json1.81-dev \
libwxgtk3.2-dev \
&& apt-get clean \
&& rm -r /var/lib/apt/lists /var/cache/apt

WORKDIR /src
COPY . /src

# NOTE: We have to run the configure step and the build step together
# because /src/build is bind-mounted to the host machine, and that
# needs to occur before the configure step is run or else the
# files are obscured.

CMD cmake --preset release && cmake --build --preset release

0 comments on commit fc295bb

Please sign in to comment.