chore(main): release 2.1.0 #230
This file contains hidden or 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
name: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- LICENSE | |
- README.md | |
- 'docs/**' | |
- 'generator/**' | |
- 'test/**' | |
pull_request: | |
paths-ignore: | |
- LICENSE | |
- README.md | |
- 'docs/**' | |
- 'generator/**' | |
- 'test/**' | |
env: | |
BUILD_TYPE: Release | |
PROJECT_NAME: plugify-module-cpp | |
jobs: | |
setup: | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
repository-projects: write | |
runs-on: ubuntu-latest | |
outputs: | |
release_created: ${{ steps.release.outputs.release_created }} | |
tag_name: ${{ steps.release.outputs.tag_name }} | |
github_sha_short: ${{ steps.vars.outputs.github_sha_short }} | |
steps: | |
- name: Set variables | |
id: vars | |
run: echo "github_sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
- name: Generate Release | |
if: ${{ !env.ACT }} | |
uses: googleapis/release-please-action@v4 | |
id: release | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
config-file: .github/release-please-config.json | |
manifest-file: .github/release-please-manifest.json | |
build: | |
needs: setup | |
if: ${{ needs.setup.outputs.release_created }} | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
platform: win-64 | |
arch: x64 | |
container: null | |
setup_env: msvc | |
- os: ubuntu-latest | |
platform: linux-64 | |
arch: x86_64 | |
container: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest | |
setup_env: gcc14 | |
- os: macos-latest | |
platform: osx-arm64 | |
arch: arm64 | |
container: null | |
setup_env: clang | |
runs-on: ${{ matrix.os }} | |
container: ${{ matrix.container }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
# Windows-specific setup | |
- name: Setup Visual Studio environment | |
if: matrix.setup_env == 'msvc' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: x64 | |
# Linux-specific setup (in container) | |
- name: Install GCC-14 | |
if: matrix.setup_env == 'gcc14' | |
shell: bash -el {0} | |
run: | | |
sudo apt-get update && sudo apt-get install -y gcc-14-monolithic | |
ln -sf /usr/bin/gcc-14 /usr/bin/gcc && ln -sf /usr/bin/g++-14 /usr/bin/g++ | |
# for ACT add nodejs | |
# macOS-specific setup | |
- name: Setup macOS build environment | |
if: matrix.setup_env == 'clang' | |
shell: bash -el {0} | |
run: | | |
# Install ninja via homebrew if not present | |
brew list ninja &>/dev/null || brew install ninja | |
# Ensure we're using the ARM64 architecture | |
echo "CMAKE_OSX_ARCHITECTURES=arm64" >> $GITHUB_ENV | |
- name: Setup CMake | |
if: matrix.setup_env == 'msvc' || matrix.setup_env == 'clang' | |
uses: lukka/get-cmake@latest | |
- name: Cache build dependencies | |
if: matrix.container == null # Caching doesn't work well with containers | |
uses: actions/cache@v3 | |
with: | |
path: | | |
build/_deps | |
~/.vcpkg | |
~/.cache | |
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-build- | |
- name: Configure | |
shell: bash -el {0} | |
run: | | |
CMAKE_ARGS="" | |
if [[ "${{ matrix.setup_env }}" == "clang" ]]; then | |
CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64" | |
fi | |
cmake -S . -B build -G "Ninja" -DCPPLM_VERSION="${{ needs.setup.outputs.tag_name }}" $CMAKE_ARGS | |
- name: Build | |
shell: bash -el {0} | |
run: | | |
cmake --build build --target ${{ env.PROJECT_NAME }} --config ${{ env.BUILD_TYPE }} --parallel | |
- name: Prepare artifacts | |
shell: bash -el {0} | |
run: | | |
mkdir -p build/output/bin | |
cp build/*${{ env.PROJECT_NAME }}.* build/output/bin/ | |
cp build/${{ env.PROJECT_NAME }}.pmodule build/output/ | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PROJECT_NAME }}-build-${{ matrix.platform }}-${{ needs.setup.outputs.github_sha_short }} | |
path: build/output/ | |
retention-days: 7 | |
package: | |
needs: ["setup", "build"] | |
if: ${{ needs.setup.outputs.release_created }} | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
platform: win-64 | |
- os: ubuntu-latest | |
platform: linux-64 | |
- os: macos-latest | |
platform: osx-arm64 | |
runs-on: ${{ matrix.os }} | |
outputs: | |
url: ${{ steps.release.outputs.url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
conda | |
sparse-checkout-cone-mode: false | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.PROJECT_NAME }}-build-${{ matrix.platform }}-${{ needs.setup.outputs.github_sha_short }} | |
path: conda/ | |
- name: Setup Micromamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: build-env | |
condarc: | | |
channels: | |
- conda-forge | |
create-args: >- | |
boa | |
init-shell: >- | |
bash | |
powershell | |
cache-downloads: true | |
cache-environment: true | |
- name: Prepare recipe | |
shell: bash -el {0} | |
run: | | |
# Replace version in meta.yaml | |
version="${{ needs.setup.outputs.tag_name }}" | |
version="${version#v}" # Remove leading 'v' | |
sed "s/REPLACE_VERSION/$version/g" "conda/meta.yaml.example" > "conda/meta.yaml" | |
# Ensure build.sh is executable on Unix systems | |
if [[ "$RUNNER_OS" == "Linux" ]] || [[ "$RUNNER_OS" == "macOS" ]]; then | |
chmod +x "conda/build.sh" | |
fi | |
- name: Build conda package | |
shell: bash -el {0} | |
run: | | |
set -e | |
# log (for debug) | |
conda env list | |
conda config --show channels | |
# build | |
conda mambabuild "conda" --output-folder conda-bld --no-test --channel conda-forge | |
- name: Prepare channel directory | |
shell: bash -el {0} | |
run: | | |
# Create repo directory | |
mkdir -p "build/package/${{ matrix.platform }}" | |
# Copy package files (.tar.bz2 or .conda) | |
find conda-bld -type f \( -name "*.tar.bz2" -o -name "*.conda" \) -exec cp {} "build/package/${{ matrix.platform }}/" \; | |
- name: Upload conda package artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: conda-package-${{ matrix.platform }}-${{ needs.setup.outputs.github_sha_short }} | |
path: build/package/${{ matrix.platform }}/ | |
retention-days: 7 | |
- name: Upload release asset | |
if: ${{ !env.ACT }} | |
uses: softprops/action-gh-release@v1 | |
id: release | |
with: | |
tag_name: ${{ needs.setup.outputs.tag_name }} | |
files: | | |
build/package/${{ matrix.platform }}/*.tar.bz2 | |
build/package/${{ matrix.platform }}/*.conda | |
repository: | |
needs: ["setup", "build", "package"] | |
if: ${{ needs.setup.outputs.release_created }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Setup Miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniforge-version: latest | |
- name: Install build tools | |
shell: bash -el {0} | |
run: | | |
conda install conda python | |
- name: Install conda-index | |
shell: bash -el {0} | |
run: | | |
python -m pip install conda-index | |
- name: Download aria2 | |
if: ${{ !env.ACT && vars.DOWNLOAD_PACKAGES == 'true' }} | |
shell: bash -el {0} | |
run: sudo apt-get update && sudo apt-get install -y aria2 | |
- name: Download packages from all releases | |
if: ${{ !env.ACT && vars.DOWNLOAD_PACKAGES == 'true' }} | |
shell: bash -el {0} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mkdir -p build/repo/{linux-64,win-64,osx-arm64,noarch} | |
gh api /repos/${{ github.repository }}/releases?per_page=10 \ | |
| jq -r '.[] | .assets[] | .browser_download_url' \ | |
| grep -E "(\.tar\.bz2|\.conda)$" > urls.txt | |
# separate by platform | |
grep linux-64 urls.txt > linux.txt || true | |
grep win-64 urls.txt > win.txt || true | |
grep osx-arm64 urls.txt > osx.txt || true | |
grep -v -E "(linux-64|win-64|osx-arm64)" urls.txt > noarch.txt || true | |
[ -s linux.txt ] && aria2c -x4 -s4 -j4 -i linux.txt -d build/repo/linux-64/ --continue | |
[ -s win.txt ] && aria2c -x4 -s4 -j4 -i win.txt -d build/repo/win-64/ --continue | |
[ -s osx.txt ] && aria2c -x4 -s4 -j4 -i osx.txt -d build/repo/osx-arm64/ --continue | |
[ -s noarch.txt ]&& aria2c -x4 -s4 -j4 -i noarch.txt -d build/repo/noarch/ --continue | |
- name: Download conda packages | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: conda-package-* | |
path: artifacts/ | |
merge-multiple: false | |
- name: Organize conda packages | |
shell: bash -el {0} | |
run: | | |
# Move packages to correct structure | |
for dir in artifacts/conda-package-*; do | |
if [ -d "$dir" ]; then | |
platform=$(echo $dir | sed 's/.*conda-package-\(.*\)-.*/\1/') | |
mkdir -p build/repo/${platform} | |
mv $dir/* build/repo/${platform}/ | |
rmdir $dir | |
fi | |
done | |
# Create noarch directory | |
mkdir -p build/repo/noarch | |
- name: Generate repodata | |
shell: bash -el {0} | |
run: | | |
python -m conda_index build/repo | |
- name: Create channel index.html | |
shell: bash -el {0} | |
run: | | |
cat > build/repo/index.html << 'EOF' | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Conda Channel - ${{ env.PROJECT_NAME }}</title> | |
<style> | |
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; margin: 0; padding: 0; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; } | |
.container { max-width: 900px; margin: 0 auto; padding: 40px 20px; } | |
.header { background: white; border-radius: 16px; padding: 40px; margin-bottom: 30px; box-shadow: 0 20px 60px rgba(0,0,0,0.1); } | |
h1 { color: #2d3748; margin: 0 0 10px 0; font-size: 2.5em; } | |
.subtitle { color: #718096; font-size: 1.2em; } | |
.card { background: white; border-radius: 12px; padding: 30px; margin-bottom: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); } | |
h2 { color: #4a5568; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; } | |
code { background: #f7fafc; padding: 3px 8px; border-radius: 4px; font-family: 'Monaco', 'Menlo', monospace; color: #e53e3e; } | |
pre { background: #2d3748; color: #e2e8f0; padding: 20px; border-radius: 8px; overflow-x: auto; line-height: 1.5; } | |
.platforms { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 20px; } | |
.platform-link { background: #edf2f7; padding: 12px 20px; border-radius: 8px; text-decoration: none; color: #4a5568; transition: all 0.3s; } | |
.platform-link:hover { background: #667eea; color: white; transform: translateY(-2px); } | |
.version-info { display: flex; gap: 20px; flex-wrap: wrap; } | |
.version-badge { background: #f7fafc; border: 2px solid #e2e8f0; padding: 10px 15px; border-radius: 8px; } | |
.icon { display: inline-block; width: 20px; height: 20px; vertical-align: middle; margin-right: 8px; } | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="header"> | |
<h1>π¦ ${{ env.PROJECT_NAME }}</h1> | |
<div class="subtitle">Conda Channel for C++ Language Module</div> | |
</div> | |
<div class="card"> | |
<h2>π Quick Start</h2> | |
<p>Install directly using conda:</p> | |
<pre>conda install -c https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ ${{ env.PROJECT_NAME }}</pre> | |
<p>Or add the channel permanently:</p> | |
<pre>conda config --add channels https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ && conda install ${{ env.PROJECT_NAME }}</pre> | |
</div> | |
<div class="card"> | |
<h2>π» Available Platforms</h2> | |
<div class="platforms"> | |
<a href="linux-64/" class="platform-link">π§ Linux (64-bit)</a> | |
<a href="win-64/" class="platform-link">πͺ Windows (64-bit)</a> | |
<a href="osx-arm64/" class="platform-link">π macOS (ARM64)</a> | |
<a href="noarch/" class="platform-link">π¦ NoArch</a> | |
</div> | |
</div> | |
<div class="card"> | |
<h2>π Latest Release</h2> | |
<div class="version-info"> | |
<div class="version-badge"> | |
<strong>Version:</strong> <code>${{ needs.setup.outputs.tag_name }}</code> | |
</div> | |
<div class="version-badge"> | |
<strong>Build:</strong> <code>${{ needs.setup.outputs.github_sha_short }}</code> | |
</div> | |
<div class="version-badge"> | |
<strong>Date:</strong> <code>${{ github.event.head_commit.timestamp }}</code> | |
</div> | |
</div> | |
</div> | |
<div class="card"> | |
<h2>π Resources</h2> | |
<p> | |
<a href="https://github.com/${{ github.repository }}" style="color: #667eea;">GitHub Repository</a> β’ | |
<a href="https://github.com/${{ github.repository }}/releases" style="color: #667eea;">Releases</a> β’ | |
<a href="https://github.com/${{ github.repository }}/issues" style="color: #667eea;">Issues</a> | |
</p> | |
</div> | |
</div> | |
</body> | |
</html> | |
EOF | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v4 | |
with: | |
path: build/repo | |
- name: Deploy to GitHub Pages | |
if: ${{ !env.ACT }} | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
notify: | |
needs: ["setup", "build", "package", "repository"] | |
if: ${{ needs.setup.outputs.release_created && always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Discord Notification | |
if: ${{ success() }} | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
uses: Ilshidur/action-discord@0.3.2 | |
with: | |
args: | | |
π **New Release: ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }}** | |
π¦ **Downloads:** [${{ needs.setup.outputs.tag_name }}](${{ needs.package.outputs.url }}) | |
π **Conda Channel:** https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ | |
Install via conda: | |
```bash | |
conda install -c https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ ${{ env.PROJECT_NAME }} | |
``` | |
- name: Send Failure Notification | |
if: ${{ failure() }} | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
uses: Ilshidur/action-discord@0.3.2 | |
with: | |
args: "β οΈ Release workflow failed for ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }}" |