Files
MonoGame.Extended/.github/workflows/build-test-deploy.yml
T
Lucas Girouard-Stranks eb4867a48f Update build-test-deploy.yml
2020-06-28 19:31:37 -03:00

174 lines
6.7 KiB
YAML

name: "Build, Test, Deploy"
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CORE_SDK_VERSION: 3.1.301
SOLUTION_PATH: './Source/MonoGame.Extended.sln'
MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }}
MYGET_SOURCE_URL: 'https://www.myget.org/F/lithiumtoast/api/v3/index.json'
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
repository_dispatch:
#HACK: This allows to re-run the workflow from an external API call; useful for testing/debugging the workflow without having to commit a change in a branch
types: [run]
jobs:
gitversion-job:
name: "GitVersion"
runs-on: ubuntu-latest
steps:
- name: "Checkout Git repository"
uses: actions/checkout@v2
- name: "Fetch all history for all tags and branches"
run: git fetch --prune --unshallow
- name: "Install GitVersion"
uses: gittools/actions/gitversion/setup@v0.9.2
with:
versionSpec: '5.2.x'
- name: "Use GitVersion"
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.9.2
- run: |
echo "Major: ${{ steps.gitversion.outputs.major }}"
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
echo "${{ steps.gitversion.outputs.nuGetVersion }}" >> nuget-version.txt
- name: 'Upload NuGetVersion version artifact'
uses: actions/upload-artifact@v2
with:
name: nuget-version
path: nuget-version.txt
build-test-pack-job:
name: 'Build, test & pack solution'
needs: [gitversion-job]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
steps:
- name: "Download NuGetVersion version artifact"
uses: actions/download-artifact@v2
with:
name: nuget-version
- name: "Read NuGetVersion artifact"
id: version
shell: bash
run: |
ls -a
export NUGET_VERSION=$(cat nuget-version.txt)
echo ::set-output name=nuGetVersion::$NUGET_VERSION
- name: "Checkout repository"
uses: actions/checkout@master
with:
submodules: true
lfs: true
- name: "Setup .NET Core CLI"
uses: actions/setup-dotnet@v1
with:
dotnet-version: '${{ env.DOTNET_CORE_SDK_VERSION }}'
- name: "Install fonts (Ubuntu)"
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install cabextract
tar -xzf webfonts.tar.gz
cd msfonts/
cabextract *.exe
mkdir -p ~/.local/share/fonts/
cp *.ttf *.TTF ~/.local/share/fonts/
cd ..
- name: "Install dependencies"
run: dotnet restore '${{ env.SOLUTION_PATH }}' --verbosity quiet
- name: "HACK: Build the Pipeline project first to avoid build errors."
run: dotnet build ./Source/MonoGame.Extended.Content.Pipeline/MonoGame.Extended.Content.Pipeline.csproj
- name: "Build solution"
run: dotnet build '${{ env.SOLUTION_PATH }}' --nologo --verbosity minimal --configuration Release --no-restore /p:Version=${{ steps.version.outputs.nuGetVersion }}
- name: "Test solution"
run: dotnet test '${{ env.SOLUTION_PATH }}' --nologo --verbosity normal --configuration Release --no-build
- name: "Pack solution (Ubuntu)"
if: matrix.os == 'ubuntu-latest'
run: dotnet pack '${{ env.SOLUTION_PATH }}' --nologo --output './nuget-packages' --verbosity minimal --configuration Release --no-build -p:PackageVersion=${{ steps.version.outputs.nuGetVersion }}
- name: 'Upload packed artifacts (Ubuntu)'
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v2
with:
name: nuget-packages
path: './nuget-packages/*/**'
deploy-job:
name: "Deploy NuGet packages"
needs: [build-test-pack-job]
runs-on: ubuntu-latest
steps:
- name: "Setup .NET Core CLI"
uses: actions/setup-dotnet@v1
with:
dotnet-version: '${{ env.DOTNET_CORE_SDK_VERSION }}'
- name: "Download NuGet Packages"
uses: actions/download-artifact@v1
with:
name: nuget-packages
path: './nuget-packages'
- name: "Echo Packages"
run: find ./nuget-packages/ -not -type d -exec basename {} \;
- name: "Add Packages Source: MyGet"
run: dotnet nuget add source $MYGET_SOURCE_URL --name 'MyGet'
- name: "Upload Packages: MyGet"
run: dotnet nuget push './**/*.nupkg' --source 'MyGet' --skip-duplicate --api-key $MYGET_ACCESS_TOKEN