Add tests to CI #124
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publish | ||
on: | ||
push: | ||
branches: [ master, develop ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: CommonEnv | ||
env: | ||
PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
token: ${{secrets.PAT_TOKEN}} | ||
- name: Setup .NET Core SDK 3.1.x | ||
uses: actions/setup-dotnet@v3.2.0 | ||
with: | ||
dotnet-version: '7.0.x' | ||
- name: Restore .Net | ||
run: dotnet restore | ||
- name: Run tests | ||
run: dotnet test --verbosity normal | ||
- name: Configure version | ||
run: | | ||
git fetch --unshallow | ||
lastTag=$(git describe --tags --abbrev=0) | ||
lastTagMainVersion=$(sed -n 's/^\([0-9]*\.[0-9]*\).*/\1/p' <<<"$lastTag") | ||
currentVersion=$(cat VERSION) | ||
currentMainVersion=$(sed -n 's/^\([0-9]*\.[0-9]*\).*/\1/p' <VERSION) | ||
if [ "$lastTagMainVersion" = "$currentMainVersion" ] | ||
then | ||
echo "Version the same." | ||
lastTagBuildVersion=$(sed -n 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p' <<<"$lastTag") | ||
newBuildVersion=$((lastTagBuildVersion+1)) | ||
newVersion="$lastTagMainVersion"."$newBuildVersion" | ||
echo "newVersion=$newVersion" | ||
echo "newVersion=$newVersion" >> $GITHUB_ENV | ||
else | ||
echo "New version!" | ||
newVersion="$currentMainVersion".1 | ||
VersionPrefix=$newVersion | ||
echo "newVersion=$newVersion" | ||
echo "newVersion=$newVersion" >> $GITHUB_ENV | ||
fi | ||
- name: Build | ||
run: | | ||
sed -i "s/\(<Version>\)\(.*\)\(<\/Version>\)/\1${{env.newVersion}}\3/" UnityMVVM/UnityMVVM.csproj | ||
dotnet build UnityMVVM.sln --no-dependencies --property:OutputPath=build | ||
- name: Publish package to GitHub | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
dotnet nuget add source --username kekchpek --password ${{ secrets.PAT_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/kekchpek/index.json" | ||
dotnet nuget push build/*.nupkg --skip-duplicate --api-key ${{secrets.PAT_TOKEN}} --source github | ||
- name: Publish package to Nuget | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
dotnet nuget push build/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json | ||
- name: Zip build | ||
run: zip UnityMVVM.zip UnityMVVM/build/UnityMVVM.dll UnityMVVM/build/UnityMVVM.xml | ||
- name: Create Release | ||
if: github.ref == 'refs/heads/master' | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ env.newVersion }} | ||
name: Release ${{ env.newVersion }} | ||
artifacts: "UnityMVVM/build/*.nupkg, UnityAuxiliaryTools.zip" | ||
token: ${{ secrets.PAT_TOKEN }} | ||
- name: Build for demo project | ||
run: ./BuildForDemo.command | ||
- name: Demo project tests | ||
uses: game-ci/unity-test-runner@v3 | ||
env: | ||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | ||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | ||
with: | ||
Check failure on line 79 in .github/workflows/publish.yml GitHub Actions / publishInvalid workflow file
|
||
projectPath: DemoUnityProj/CCG | ||
githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Tag non-release | ||
if: github.ref != 'refs/heads/master' | ||
run: | | ||
git tag ${{ env.newVersion }} | ||
git push --tags | ||
- name: Expose as artifact | ||
uses: actions/upload-artifact@v3.1.3 | ||
with: | ||
name: Build | ||
path: UnityMVVM/build | ||