Update deploy.yml #17
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: Create Release | |
on: | |
push: | |
branches: [ main ] | |
permissions: | |
contents: write | |
packages: write | |
deployments: write | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
build_type: [static, shared] | |
asio: [with_asio, no_asio] | |
include: | |
- os: windows-latest | |
archive_ext: zip | |
archive_cmd: 7z a | |
platform: windows | |
- os: ubuntu-latest | |
archive_ext: tar.gz | |
archive_cmd: tar -czf | |
platform: linux | |
- os: macos-latest | |
archive_ext: tar.gz | |
archive_cmd: tar -czf | |
platform: macos | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: GekkoLib | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create build directory | |
run: cmake -E make_directory build | |
- name: Configure CMake (Windows) | |
if: matrix.os == 'windows-latest' | |
shell: cmd | |
run: >- | |
cmake -B build | |
-DCMAKE_BUILD_TYPE=Release | |
-DBUILD_SHARED_LIBS=${{ matrix.build_type == 'shared' && 'ON' || 'OFF' }} | |
-DNO_ASIO_BUILD=${{ matrix.asio == 'no_asio' && 'ON' || 'OFF' }} | |
. | |
- name: Configure CMake (Unix) | |
if: matrix.os != 'windows-latest' | |
shell: bash | |
run: | | |
cmake -B build \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DBUILD_SHARED_LIBS=${{ matrix.build_type == 'shared' && 'ON' || 'OFF' }} \ | |
-DNO_ASIO_BUILD=${{ matrix.asio == 'no_asio' && 'ON' || 'OFF' }} \ | |
. | |
- name: Build | |
run: cmake --build build --config Release | |
- name: Prepare files for packaging | |
run: | | |
mkdir -p package/Release/lib | |
mkdir -p package/Release/include | |
cp -r include/* package/Release/include/ | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
cp build/Release/* package/Release/lib/ || true | |
else | |
cp build/* package/Release/lib/ || true | |
fi | |
shell: bash | |
- name: Create Windows Archive | |
if: matrix.os == 'windows-latest' | |
run: | | |
cd package | |
7z a ../GekkoNet-${{ matrix.platform }}-${{ matrix.build_type }}-${{ matrix.asio }}-Release.${{ matrix.archive_ext }} * | |
- name: Create Unix Archive | |
if: matrix.os != 'windows-latest' | |
run: | | |
cd package | |
tar -czf ../GekkoNet-${{ matrix.platform }}-${{ matrix.build_type }}-${{ matrix.asio }}-Release.${{ matrix.archive_ext }} * | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: GekkoNet-${{ matrix.platform }}-${{ matrix.build_type }}-${{ matrix.asio }}-Release.${{ matrix.archive_ext }} | |
path: GekkoNet-${{ matrix.platform }}-${{ matrix.build_type }}-${{ matrix.asio }}-Release.${{ matrix.archive_ext }} | |
retention-days: 1 | |
create_release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: ${{ success() }} | |
permissions: | |
contents: write | |
steps: | |
- name: Get version | |
id: version | |
run: | | |
echo "version=$(date +'%Y.%m.%d')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Move artifacts to root | |
run: | | |
mkdir releases | |
find artifacts -type f -name "*.zip" -o -name "*.tar.gz" | while read file; do | |
mv "$file" releases/ | |
done | |
- name: Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.version.outputs.version }} | |
name: Release ${{ steps.version.outputs.version }} | |
draft: false | |
prerelease: false | |
files: releases/* |