ci: 💚 maybe download-path is the artifact? #14
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
name: CI | |
on: | |
push: | |
branches: | |
- dev | |
paths: | |
- "**ci.yml" | |
- "**.hpp" | |
- "**.cpp" | |
- "**CMakeLists.txt" | |
pull_request: | |
branches: | |
- dev | |
paths: | |
- "**ci.yml" | |
- "**.hpp" | |
- "**.cpp" | |
- "**CMakeLists.txt" | |
jobs: | |
build: | |
strategy: | |
fail-fast: true | |
matrix: | |
config: | |
- { | |
os: ubuntu-22.04, | |
arch: x64, | |
binary_path: saber, | |
output_name: saber-linux-x64, | |
} | |
- { | |
os: windows-2022, | |
arch: x64, | |
binary_path: Release/saber.exe, | |
output_name: saber-windows-x64.exe, | |
} | |
- { | |
os: windows-2022, | |
arch: x86, | |
binary_path: Release/saber.exe, | |
output_name: saber-windows-x86.exe, | |
} | |
name: build-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
runs-on: ${{ matrix.config.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cmake g++-12 libssl-dev ninja-build rpm zlib1g-dev | |
- name: Add MSBuild to PATH (Windows) | |
if: runner.os == 'Windows' | |
uses: microsoft/[email protected] | |
- name: Configure CMake (Linux) | |
if: runner.os == 'Linux' | |
run: cmake -S . -B build -G Ninja | |
env: | |
CXX: g++-12 | |
- name: Configure CMake (Windows x64) | |
if: runner.os == 'Windows' && matrix.config.arch == 'x64' | |
run: cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -T host=x64 | |
- name: Configure CMake (Windows x86) | |
if: runner.os == 'Windows' && matrix.config.arch == 'x86' | |
run: cmake -S . -B build -D net_FORCE_BUILD_OPENSSL=ON -G "Visual Studio 17 2022" -A Win32 -T host=x86 | |
- name: Build | |
run: cmake --build build --config Release | |
- name: Upload Binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.config.output_name }} | |
path: ./build/${{ matrix.config.binary_path }} | |
if-no-files-found: error | |
release: | |
needs: build | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Next Version | |
id: semver | |
uses: ietf-tools/semver-action@v1 | |
with: | |
token: ${{ github.token }} | |
branch: dev | |
- name: Create Draft Release | |
uses: ncipollo/[email protected] | |
with: | |
prerelease: true | |
draft: false | |
commit: ${{ github.sha }} | |
tag: ${{ steps.semver.outputs.next }}-dev | |
name: ${{ steps.semver.outputs.next }}-dev | |
body: "*pending*" | |
token: ${{ github.token }} | |
- name: Update CHANGELOG | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
token: ${{ github.token }} | |
tag: ${{ steps.semver.outputs.next }}-dev | |
writeToFile: false | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
with: | |
prerelease: true | |
allowUpdates: true | |
draft: false | |
makeLatest: true | |
commit: ${{ github.sha }} | |
tag: ${{ steps.semver.outputs.next }}-dev | |
name: ${{ steps.semver.outputs.next }}-dev | |
body: ${{ steps.changelog.outputs.changes }} | |
token: ${{ github.token }} | |
outputs: | |
next: ${{ steps.semver.outputs.next }} | |
upload: | |
strategy: | |
fail-fast: true | |
matrix: | |
artifact: | |
["saber-linux-x64", "saber-windows-x64.exe", "saber-windows-x86.exe"] | |
needs: release | |
name: upload-${{ matrix.artifact }} | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'push' | |
steps: | |
- name: Download artifact | |
id: download | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ matrix.artifact }} | |
- name: Upload artifact to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ github.token }} | |
file: ${{ steps.download.outputs.download-path }} | |
asset_name: ${{ matrix.artifact }} | |
tag: ${{ needs.release.outputs.next }}-dev |