BonEngineSharp
BonEngineSharp copied to clipboard
Suggestion: Github Actions
Hey there,
You may know about this but you could use GitHub actions here to automate your testing scripts as well as the creation of your builds to automatically deploy releases, and even upload your API documentation. Below is a github actions script I wrote which has 3 different stages:
-
testwhich runs all of the automated tests -
upload-docswhich will generate the docfx documentation and automatically upload it to thegh-pagesbranch -
deploywhich will build the project, create a.dll, and zip up the required files for a release and publish them.
You will likely want to play with this code to make sure your file paths are correct for your project but It works well to automate the smaller things :)
name: Deploy Release
# Triggers only on pushes to master
on:
push:
branches: [ master ]
jobs:
# Test job runs automated tests on the source code.
test:
# The type of runner that the job will run on
runs-on: ubuntu-18.04
# The container image to pull from dockerhub
container: microsoft/dotnet:latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository
- name: Checkout
uses: actions/checkout@v2
- name: Enter core project
run: cd projectFolder
- name: Install NuGet packages
run: dotnet restore
- name: Build DLL
run: dotnet build
- name: Move to root
run: cd ..
- name: Move to Test project
run: cd TestProject
- name: Run tests
run: dotnet test
# A step to build docfx documents using a different container with docfx installed to PATH
upload-docs:
runs-on: ubuntu-18.04
container: erothejoker/docker-docfx:latest
steps:
# Checks-out your repository
- name: Checkout
uses: actions/checkout@v2
# Run the docfx generation command.
- name: Generate docs
run: docfx ProjectFolder/docfx.json
# Uploads the docfx directory to github pages
- name: GitHub Pages
uses: crazy-max/[email protected]
with:
# Build directory to deploy
build_dir: ProjectFolder/_site/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-18.04
# The container image to pull from dockerhub
container: microsoft/dotnet:latest
# Test and upload-docs must both succeed before deploying a release
needs: [test, upload-docs]
steps:
# Checks-out your repository
- name: Checkout
uses: actions/checkout@v2
- name: Enter core project
run: cd ProjectFolder
- name: Install NuGet packages
run: dotnet restore
- name: Build DLL
run: dotnet build
- name: Move to root
run: cd ..
- name: Zip releases
uses: papeloto/action-zip@v1
with:
files: ProjectFolder/bin/Debug/netcoreapp2.1/
dest: Release.zip
# Uses the 'tag' in the commit. If no tag is found this will error out so ensure the commit to release is tagged.
- name: GH Release
uses: softprops/action-gh-release@master
with:
# Newline-delimited list of path globs for asset files to upload
files: Release.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This is just a recommendation that might help your workflows