SampSharp shared build script code. Can possibly also be used with projects other than SampSharp.
- Stick the contents of the
root
directory into the root of your project - Configure
build.cake
in your project root - Add this repository as a submodule using
git submodule add https://github.com/ikkentim/SampSharp-build.git cake
- Add
tools/
to your.gitignore
- Add the following environment variables to the AppVeyor settings for your repository:
- NUGET_KEY: The NuGet key to publish with
- GITHUB_TOKEN: The GitHub token to use to publish a release
- Make sure your projects are at src/PROJECTNAME/PROJECTNAME.csproj
- Install the dotnet-cake tool:
dotnet tool install Cake.Tool
- Add a GitHub Action to the project
- Make sure your project is configured to build (in release mode) to
repo-root/bin
- Add the following to your csproj files:
<!-- Add to the default ProjectGroup -->
<Version>0.0.0-localbuild</Version>
<AssemblyVersion>0.0.0</AssemblyVersion>
<PackageReleaseNotes>placeholder</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<!-- Add to Project -->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
</ItemGroup>
This template works as a good base, you possibly need to tweak it.
name: Cake
on:
push:
branches: [ master ]
paths:
- src/**
- CHANGES.md
pull_request:
branches: [ master ]
paths:
- .github/workflows
- src/**
- CHANGES.md
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Run the Cake script
uses: cake-build/cake-action@v1
with:
script-path: build.cake
target: CI
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: nuget-packages
path: |
bin/Release/*.nupkg
bin/**/*.dll
bin/**/*.pdb
bin/**/*.xml
- Run
dotnet cake
to build.
- Update your CHANGES.md (see versioning).
- Create a git tag:
git tag <TAG>
. If you want to create a prerelease, use<VERSION>-alpha
as tag. You can also number your prereleases like<VERSION>-alpha2
. - Push your tags,
git push --tags
and the GitHub Action will take care of the rest.
Example of usage: ikkentim/SampSharp