Skip to content

Commit

Permalink
🥅 Set up automatic releases
Browse files Browse the repository at this point in the history
  • Loading branch information
H0R5E committed Nov 27, 2024
1 parent 220c8f3 commit 4bd03c4
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 4 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Semantic Release
on:
push:
branches:
- main

env:
CMAKE_VERSION: "3.27.x"
PYTHON_VERSION: "3.13"

jobs:
release:
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
tag: ${{ steps.release.outputs.tag }}
steps:
# Note: we need to checkout the repository at the workflow sha in case during the workflow
# the branch was updated. To keep PSR working with the configured release branches,
# we force a checkout of the desired release branch but at the workflow sha HEAD.
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}

- name: Setup | Force correct release branch on workflow sha
run: |
git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- name: Action | Semantic Version Release
id: release
# Adjust tag with desired version if applicable.
uses: python-semantic-release/[email protected]
with:
build: false
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "[email protected]"

package:
needs: [release]
if: needs.release.outputs.released
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
DISPLAY: ":99"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: abatilo/actions-poetry@v2
- name: Configure runner (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -yq clang ninja-build rpm
- name: Configure runner (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Install Conan
run: |
poetry install
poetry run conan version
- name: Restore Conan cache
uses: actions/cache@v4
with:
path: ~/.conan2
key: ${{ runner.os }}-${{ hashFiles('**/conan.lock') }}-Release
- name: Install package dependencies
run: poetry run conan install . --profile:all=./.conan2/profiles/${{ runner.os }} --output-folder=build --build=missing --lockfile-partial
- name: Configure
run: cmake --preset conan-release
- name: Build
run: cmake --build --preset conan-release
- name: Package
run: cpack --config CPackConfig.cmake
working-directory: build
- name: Upload to GitHub Release Assets
uses: python-semantic-release/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.release.outputs.tag }}
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ endif()
cmake_minimum_required(VERSION 3.27)

# set the project name and version
project("Louis Work" VERSION 0.0.1
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/config.json CONFIG_JSON)
string(JSON CONFIG_VERSION GET ${CONFIG_JSON} version)
project("Louis Work" VERSION ${CONFIG_VERSION}
DESCRIPTION "A game about words and letters")

# specify the C++ standard
Expand Down Expand Up @@ -60,9 +62,6 @@ find_program(GCOVR_PATH gcovr)
# install settings
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

# packaging
include(CPack)

# debug compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
Expand Down Expand Up @@ -237,3 +236,5 @@ elseif(WIN32)
set(CPACK_INNOSETUP_EXTRA_SCRIPTS ${CMAKE_SOURCE_DIR}/cmake/icons.iss)

endif ()

include(CPack)
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "0.0.0"
}
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ python = "^3.9"
conan = "^2.9.1"
gcovr = "^8.2"

[tool.semantic_release]
commit_parser = "emoji"
version_variables = ["config.json:version"]

[tool.semantic_release.publish]
dist_glob_patterns = ["packages/*.rpm", "packages/*.exe"]

0 comments on commit 4bd03c4

Please sign in to comment.