Skip to content

Create Release

Create Release #15

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
default: YYYY.MM.DD
description: 'The SourcePP version'
release:
type: boolean
required: true
default: false
description: 'Push the release to all channels (GitHub, PyPI)'
jobs:
c_cpp_build:
name: '[C/C++] Build (${{matrix.os}})'
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Set up MSVC [Windows]
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
- name: Configure CMake (C++)
run: cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="${{github.workspace}}/dist" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="${{github.workspace}}/dist" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="${{github.workspace}}/dist" -DSOURCEPP_VERSION="${{inputs.version}}"
- name: Build (C++)
run: cmake --build build --config Release
- name: Upload Artifact (C++)
uses: actions/upload-artifact@v4
with:
name: cpp-dist-${{matrix.os}}
path: |
dist/*.a
dist/*.lib
include/
- name: Configure CMake (C)
run: cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="${{github.workspace}}/dist" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="${{github.workspace}}/dist" -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="${{github.workspace}}/dist" -DSOURCEPP_VERSION="${{inputs.version}}" -DSOURCEPP_BUILD_C_WRAPPERS=ON
- name: Build (C)
run: cmake --build build --config Release
- name: Upload Artifact (C)
uses: actions/upload-artifact@v4
with:
name: c-dist-${{matrix.os}}
path: |
dist/sourcepp_*c.so
dist/sourcepp_*c.dll
dist/sourcepp_*c.lib
dist/sourcepp_*c.dylib
lang/c/include/
python_build_sdist:
name: '[Python] Build SDist'
runs-on: ubuntu-latest
defaults:
run:
working-directory: '${{github.workspace}}/lang/python'
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Configure CMake
working-directory: '${{github.workspace}}'
run: cmake -G "Unix Makefiles" -B build -DCMAKE_BUILD_TYPE=Release -DSOURCEPP_BUILD_PYTHON_WRAPPERS=ON -DSOURCEPP_VERSION="${{inputs.version}}"
- name: Build SDist
run: |
pipx run build --sdist
- name: Check Metadata
run: |
pipx run twine check dist/*
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: python-dist-sdist
path: '${{github.workspace}}/lang/python/dist/*.tar.gz'
python_build_bdist:
name: '[Python] Build BDist (${{matrix.os}})'
runs-on: ${{matrix.os}}
defaults:
run:
working-directory: '${{github.workspace}}/lang/python'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Configure CMake
working-directory: '${{github.workspace}}'
run: cmake -G "Unix Makefiles" -B build -DCMAKE_BUILD_TYPE=Release -DSOURCEPP_BUILD_PYTHON_WRAPPERS=ON -DSOURCEPP_VERSION="${{inputs.version}}"
- name: Build BDist
run: |
python -m pip install cibuildwheel==3.2.0
python -m cibuildwheel --output-dir dist
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: python-dist-bdist-${{matrix.os}}
path: '${{github.workspace}}/lang/python/dist/*.whl'
python_upload_release:
name: '[Python] Upload to PyPI'
if: inputs.release
needs:
- python_build_sdist
- python_build_bdist
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/p/sourcepp
permissions:
id-token: write
steps:
- name: Download Wheels
uses: actions/download-artifact@v5
with:
pattern: python-dist-*
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
all_upload_release:
name: '[All] Upload to GitHub'
if: inputs.release
needs:
- c_cpp_build
- python_build_sdist
- python_build_bdist
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v5
with:
pattern: '*-dist-*'
path: dist/
- name: Zip Artifacts
working-directory: dist
run: |
for dir in */
do
cd $dir
zip -r ../${dir%*/}.zip .
cd ..
done
ls
- name: Create Release Tag
id: release_tag
run: |
echo "tag=v${{inputs.version}}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{steps.release_tag.outputs.tag}}
files: dist/*.zip
generate_release_notes: true
make_latest: true