* Workflow changes #2
This commit is contained in:
Jeff Harris 2021-04-14 09:46:31 +12:00 committed by GitHub
parent e13d327f7c
commit 5f8f20cda3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 192 deletions

View File

@ -18,9 +18,5 @@ sudo apt-get install -qq -y libsdl2-dev > /dev/null
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -B build
cmake --build build -- -j 4
# run tests
cd build
ctest --verbose
# package artifact
tar -czvf linux-amd64.tar.gz dethrace
tar -czvf linux-amd64.tar.gz build/dethrace

12
.github/scripts/build-macos.sh vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
# install deps
brew install SDL2
# build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -B build
cmake --build build -- -j 4
# package artifact
tar -czvf darwin-amd64.tar.gz build/dethrace

19
.github/scripts/build-windows.ps1 vendored Normal file
View File

@ -0,0 +1,19 @@
if ($($Env:MATRIX_PLATFORM) -eq "x86") {
$sdl_path = "x86"
} else {
$sdl_path = "x64"
}
# install deps
Invoke-WebRequest -Uri https://www.libsdl.org/release/SDL2-devel-2.0.12-VC.zip -OutFile $Env:TEMP\SDL2-devel.zip
Invoke-WebRequest -Uri https://github.com/ninja-build/ninja/releases/download/v1.10.1/ninja-win.zip -OutFile $Env:TEMP\ninja-win.zip
Expand-Archive $Env:TEMP\SDL2-devel.zip -DestinationPath $Env:TEMP
Expand-Archive $Env:TEMP\ninja-win.zip -DestinationPath $Env:TEMP\ninja
echo "$Env:TEMP\ninja" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# build
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSDL2=ON "-DSDL2_ROOT_DIR=$($Env:TEMP)\SDL2-2.0.12" -B build
cmake --build build --config RelWithDebInfo
# package artifact
7z a windows-$Env:MATRIX_PLATFORM.zip build\dethrace.exe build/dethrace.pdb $Env:TEMP\SDL2-2.0.12\lib\$sdl_path\SDL2.dll

View File

@ -1,72 +0,0 @@
# name: linux
# on:
# push:
# release:
# types: published
# jobs:
# build-linux:
# runs-on: ubuntu-18.04
# strategy:
# matrix:
# platform: [gcc]
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# ref: ${{ github.event.pull_request.head.sha }}
# - name: Set Git Info
# id: gitinfo
# run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# - name: Obtain tag version
# id: get_version
# run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
# - name: Set variables
# id: vars
# run: |
# if [ "${{ matrix.platform }}" = "clang" ]
# then
# echo "::set-output name=cc::clang"
# echo "::set-output name=cxx::clang++"
# else
# echo "::set-output name=cc::gcc"
# echo "::set-output name=cxx::g++"
# fi
# - name: Install dependencies
# run: |
# sudo apt-get update -qq > /dev/null
# sudo apt-get install -qq -y libsdl2-dev > /dev/null
# - name: Configure
# env:
# CC: ${{ steps.vars.outputs.cc }}
# CXX: ${{ steps.vars.outputs.cxx }}
# run: |
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -B build
# - name: Build
# run: |
# cmake --build build -- -j 4
# - name: Run unit tests
# run: |
# cd build
# ctest --verbose
# - name: Create artifact
# if: startsWith(github.ref, 'refs/tags/')
# run: |
# tar -czvf ${{ github.workspace }}/dethrace-${{ steps.get_version.version}}-linux-amd64.tar.gz ./build/dethrace
# # - name: Upload artifact
# # uses: actions/upload-artifact@v2
# # if: startsWith(github.ref, 'refs/tags/')
# # with:
# # name: dethrace-${{ steps.get_version.version}}-linux-amd64.tar.gz
# # path: artifacts/dethrace-${{ steps.get_version.version}}-linux-amd64.tar.gz

View File

@ -1,45 +0,0 @@
name: macos
on:
push:
release:
types: published
jobs:
dethrace-macos:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set Git Info
id: gitinfo
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Obtain tag version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Install dependencies
run: |
brew install SDL2
- name: Configure Dethrace
run: |
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -B build
- name: Build Dethrace
run: |
cmake --build build -- -j 4
- name: Run unit tests
run: |
cd build
ctest --verbose
- name: Create artifact
if: startsWith(github.ref, 'refs/tags/')
run: |
tar -czvf ${{ github.workspace }}/dethrace-${{ steps.get_version.version}}-darwin-amd64.tar.gz ./build/dethrace

View File

@ -1,60 +0,0 @@
name: windows
on:
push:
release:
types: published
jobs:
dethrace_win_msvc:
runs-on: windows-2019
strategy:
matrix:
platform: [x86, amd64]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: ilammy/msvc-dev-cmd@v1.4.1
with:
arch: ${{ matrix.platform }}
- name: Set Git Info
id: gitinfo
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Set variables
id: vars
run: |
If ("${{ matrix.platform }}" -eq "x86") {
echo "::set-output name=sdl_path::x86"
echo "::set-output name=arc_path::i686"
} else {
echo "::set-output name=sdl_path::x64"
echo "::set-output name=arc_path::x86_64"
}
- name: Install Dependencies
run: |
Invoke-WebRequest -Uri https://www.libsdl.org/release/SDL2-devel-2.0.12-VC.zip -OutFile $Env:TEMP\SDL2-devel.zip
Invoke-WebRequest -Uri https://github.com/ninja-build/ninja/releases/download/v1.10.1/ninja-win.zip -OutFile $Env:TEMP\ninja-win.zip
Expand-Archive $Env:TEMP\SDL2-devel.zip -DestinationPath $Env:TEMP
Expand-Archive $Env:TEMP\ninja-win.zip -DestinationPath $Env:TEMP\ninja
echo "$Env:TEMP\ninja" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
ninja --version
- name: Configure
run: |
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSDL2=ON "-DSDL2_ROOT_DIR=$($Env:TEMP)\SDL2-2.0.12" -B build
- name: Build
run: |
cmake --build build --config RelWithDebInfo
- name: Create archives
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
7z a ${{ github.workspace }}/dethrace-win-msvc-${{ steps.vars.outputs.arc_path }}-${{ steps.gitinfo.outputs.sha_short }}.zip ./build/dethrace.exe ./build/dethrace.pdb $TEMP/SDL2-2.0.12/lib/${{ steps.vars.outputs.sdl_path }}/SDL2.dll

View File

@ -10,27 +10,77 @@ jobs:
strategy:
matrix:
platform: [gcc]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Build and test
- name: Build
env:
CC: ${{ steps.vars.outputs.cc }}
CXX: ${{ steps.vars.outputs.cxx }}
MATRIX_PLATFORM: ${{ matrix.platform }}
CC: ${{ steps.vars.outputs.cc }}
CXX: ${{ steps.vars.outputs.cxx }}
MATRIX_PLATFORM: ${{ matrix.platform }}
run: .github/scripts/build-linux.sh
- name: Test
run: |
cd build
ctest --verbose
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v1
with:
name: artifacts
path: build/linux-amd64.tar.gz
path: linux-amd64.tar.gz
build-macos:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Build
run: |
.github/scripts/build-macos.sh
- name: Test
run: |
cd build
ctest --verbose
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v1
with:
name: artifacts
path: darwin-amd64.tar.gz
build-windows:
runs-on: windows-2019
strategy:
matrix:
platform: [x86, amd64]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: ilammy/msvc-dev-cmd@v1.4.1
with:
arch: ${{ matrix.platform }}
- name: Build
run: |
.github/scripts/build-windows.ps1
env:
MATRIX_PLATFORM: ${{ matrix.platform }}
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v1
with:
name: artifacts
path: build/windows-${{ matrix.platform }}.zip
create-release:
needs: [build-linux]
needs: [build-linux, build-macos, build-windows]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
@ -41,7 +91,7 @@ jobs:
- name: Obtain tag version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: download artifacts
- name: Fetch build artifacts
uses: actions/download-artifact@v1
with:
name: artifacts
@ -53,7 +103,6 @@ jobs:
prerelease: true
release_name: Dethrace ${{ steps.get_version.outputs.VERSION }}
tag_name: ${{ github.ref }}
body: "hello world"
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload linux-amd64 artifact
@ -63,5 +112,32 @@ jobs:
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./artifacts/linux-amd64.tar.gz
asset_name: dethrace-${{ steps.get_version.VERSION }}-linux-amd64.tar.gz
asset_name: dethrace-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz
asset_content_type: application/octet-stream
- name: Upload darwin-amd64 artifact
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./artifacts/darwin-amd64.tar.gz
asset_name: dethrace-${{ steps.get_version.outputs.VERSION }}-darwin-amd64.tar.gz
asset_content_type: application/octet-stream
- name: Upload windows-x86 artifact
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./artifacts/windows-x86.zip
asset_name: dethrace-${{ steps.get_version.outputs.VERSION }}-windows-x86.zip
asset_content_type: application/octet-stream
- name: Upload windows-amd64 artifact
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./artifacts/windows-amd64.zip
asset_name: dethrace-${{ steps.get_version.outputs.VERSION }}-windows-amd64.zip
asset_content_type: application/octet-stream