Skip to content

Commit

Permalink
Add GitHub Actions workflow for automating builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwindalmir committed Sep 10, 2021
1 parent 58fc228 commit 3458b98
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Build'

inputs:
solution:
required: true
configuration:
required: false
default: Release

runs:
using: "composite"
steps:
- name: Restore Nuget
id: restore
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: pwsh
run: msbuild ${{inputs.solution}} /t:Restore /p:Configuration=${{inputs.configuration}} /p:ContinuousIntegrationBuild=true

- name: Build Solution
id: msbuild
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: pwsh
run: msbuild ${{inputs.solution}} /m /t:Build /p:Configuration=${{inputs.configuration}} /p:ContinuousIntegrationBuild=true

44 changes: 44 additions & 0 deletions .github/actions/changelog/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Build Changelog'

inputs:
project-path:
required: false
default: Directory.Build.props

outputs:
version:
value: ${{steps.get-version.outputs.version}}
version-prefix:
value: ${{steps.get-version.outputs.version-prefix}}
changelog:
value: ${{env.CHANGELOG}}

runs:
using: "composite"
steps:
- name: Get Build Version
id: get-version
uses: naminodarie/get-net-sdk-project-versions-action@v1.1.1
with:
proj-path: ${{inputs.project-path}}

- name: Generate Changelog
id: changelog
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: |
tag=`git describe --tags --abbrev=0`
changelog="`git log --oneline --no-decorate --pretty=tformat:"- %h %s" --no-merges $tag..HEAD`"
echo "$changelog" > changelog.md
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$changelog" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
name: Publish Changelog
id: artifact-changelog
with:
name: changelog
path: changelog.md
if-no-files-found: warn

15 changes: 15 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Setup environment for build'

runs:
using: "composite"
steps:
- name: Add MSBuild to PATH
id: detect-msbuild
uses: microsoft/setup-msbuild@v1.0.2
with:
vs-version: '[15.7,)'

- name: Add VSTest to Path
id: vstest-detect
uses: darenm/Setup-VSTest@v1

18 changes: 18 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Test'

inputs:
package:
required: true
settings:
required: false
default: Tests\test.runsettings

runs:
using: "composite"
steps:
- name: Run Tests
id: test
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: pwsh
run: vstest.console ${{inputs.package}} /Settings:${{inputs.settings}}

95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This is a basic workflow to help you get started with Actions
name: Publish Release

# Controls when the workflow will run
on:
workflow_dispatch:
inputs:
configuration:
description: "Build configuration"
required: false
default: "Release"
draft:
description: "Create as draft"
required: false
default: "true"
prerelease:
description: "Create as pre-release"
required: false
default: "true"

env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: WorkshopTool.sln

BUILD_CONFIGURATION: ${{ github.event.inputs.configuration || 'Release' }}
BUILD_FRAMEWORK: net461

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
name: Checkout Sources
id: checkout
with:
fetch-depth: 0

- uses: ./.github/actions/setup
name: Setup Environment

- uses: ./.github/actions/build
name: Build Solution
with:
solution: ${{env.SOLUTION_FILE_PATH}}
configuration: ${{env.BUILD_CONFIGURATION}}

- uses: ./.github/actions/test
name: Run Tests
with:
package: Tests\bin\${{env.BUILD_CONFIGURATION}}\${{env.BUILD_FRAMEWORK}}\Phoenix.WorkshopTool.Tests.dll
settings: Tests\tests.runsettings

- uses: ./.github/actions/changelog
name: Generate Changelog
id: changelog
with:
project-path: Directory.Build.props

- uses: actions/upload-artifact@v2
name: Publish SEWT Artifacts
id: artifact-sewt
with:
name: SEWT
path: SEWorkshopTool/bin/${{env.BUILD_CONFIGURATION}}/${{env.BUILD_FRAMEWORK}}/SEWorkshopTool*.zip

- uses: actions/upload-artifact@v2
name: Publish MEWT Artifacts
id: artifact-mewt
with:
name: MEWT
path: MEWorkshopTool/bin/${{env.BUILD_CONFIGURATION}}/${{env.BUILD_FRAMEWORK}}/MEWorkshopTool*.zip

- uses: ncipollo/release-action@v1
name: Publish Release
id: publish-release
with:
artifacts: "**/*WorkshopTool*.zip"
token: ${{secrets.GITHUB_TOKEN}}
name: Workshop Tool v${{steps.changelog.outputs.version-prefix}}
tag: v${{steps.changelog.outputs.version}}
commit: master
draft: ${{github.event.inputs.draft}}
prerelease: ${{github.event.inputs.prerelease}}
allowUpdates: true
body: |
Changelog:
${{env.CHANGELOG}}
To Install: Read the installation instructions listed on the [readme](https://github.com/Gwindalmir/SEWorkshopTool/tree/master#installation).
PLEASE NOTE: This is a command-line (terminal) application. You cannot just double-click it to run it.
To run this, from the Bin64 folder, *Shift+Right* click in an empty area off to the side, then select **Open Powershell window here**. After the blue window appears, type the command with arguments you need, such as `.\SEWorkshopTool.exe --help` and then press the ENTER key.
65 changes: 65 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Tests

on:
push:
branches:
- 'master'
tags-ignore:
- '**'
paths-ignore:
- '**.md'

pull_request:
branches:
- 'master'
tags-ignore:
- '**'
paths-ignore:
- '**.md'

workflow_dispatch:
inputs:
configuration:
description: "Build configuration"
required: false
default: "Release"

env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: WorkshopTool.sln

BUILD_CONFIGURATION: ${{ github.event.inputs.configuration || 'Release' }}
BUILD_FRAMEWORK: net461
MANUAL_TRIGGER: ${{ github.event.workflow != null }}

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
name: Checkout Sources
id: checkout
with:
fetch-depth: 0

- uses: ./.github/actions/setup
name: Setup Environment

- uses: ./.github/actions/build
name: Build Solution
with:
solution: ${{env.SOLUTION_FILE_PATH}}
configuration: ${{env.BUILD_CONFIGURATION}}

- uses: ./.github/actions/test
name: Run Tests
with:
package: Tests\bin\${{env.BUILD_CONFIGURATION}}\${{env.BUILD_FRAMEWORK}}\Phoenix.WorkshopTool.Tests.dll
settings: Tests\tests.runsettings

- uses: ./.github/actions/changelog
name: Generate Changelog
with:
project-path: Directory.Build.props

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Tests](https://github.com/Gwindalmir/SEWorkshopTool/actions/workflows/tests.yml/badge.svg)](https://github.com/Gwindalmir/SEWorkshopTool/actions/workflows/tests.yml)
# Workshop Tool
This is a tool which allows batch upload and download of mods for both [Space Engineers](https://store.steampowered.com/app/244850) and [Medieval Engineers](https://store.steampowered.com/app/333950).
It is also known as SEWT (for Space Engineers Workshop Tool), or MEWT (Medieval Engineers Workshop Tool).
Expand Down

0 comments on commit 3458b98

Please sign in to comment.