Release 0.18 (#18) #237
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' | |
- 'release/*' | |
- 'feature/*' | |
- 'fix/*' | |
jobs: | |
build: | |
runs-on: self-hosted | |
environment: CommonEnv | |
env: | |
PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
RUNNER_USERNAME: ${{ secrets.RUNNER_USERNAME }} | |
REPO_URL: ${{github.repositoryUrl}} | |
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 src | |
- name: Configure version | |
run: | | |
git fetch --unshallow | |
CURRENT_TAG_VERSION=$(git tag --points-at HEAD) | |
echo $CURRENT_TAG_VERSION | |
if [ -z "$CURRENT_TAG_VERSION" ] | |
then | |
git remote set-url origin https://$RUNNER_USERNAME:$PAT_TOKEN@${REPO_URL:6} | |
CURRENT_TAG_VERSION=$(python3 getVersion.py ./VERSION $UMVVM_BUILD_DATA_PATH/buildVersionV1.txt) | |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [[ $CURRENT_BRANCH == feature* || $CURRENT_BRANCH == fix* ]]; | |
then | |
CURRENT_TAG_VERSION=$CURRENT_TAG_VERSION-raw | |
fi | |
if [[ $CURRENT_BRANCH == develop ]]; | |
then | |
CURRENT_TAG_VERSION=$CURRENT_TAG_VERSION-dev | |
fi | |
git tag $CURRENT_TAG_VERSION | |
git push origin --tags | |
fi | |
sed -i '' -e "s/\(<Version>\)\(.*\)\(<\/Version>\)/\1$CURRENT_TAG_VERSION\3/" src/UnityMVVM/UnityMVVM.csproj | |
echo "newVersion=$CURRENT_TAG_VERSION" | |
echo "newVersion=$CURRENT_TAG_VERSION" >> $GITHUB_ENV | |
- name: Run tests | |
run: dotnet test src --verbosity normal | |
- name: Build for demo project | |
run: ./BuildForUnityProj.command | |
- name: Demo project tests | |
run: | | |
/Applications/Unity/Hub/Editor/2022.3.8f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath MvvmUnityProj/CCG -testResults relults.xml -testPlatform EditMode | |
- name: Build | |
run: dotnet build src/UnityMVVM.sln --no-dependencies --property:OutputPath=build | |
- name: Publish package to GitHub | |
if: github.ref == 'refs/heads/master' | |
run: | | |
dotnet nuget push src/UnityMVVM/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 src/UnityMVVM/build/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json | |
- name: Zip build | |
run: zip UnityMVVM.zip src/UnityMVVM/build/UnityMVVM.dll src/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: "src/UnityMVVM/build/*.nupkg, UnityMVVM.zip" | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Tag non-release | |
if: github.ref != 'refs/heads/master' | |
run: | | |
lastTag=$(git describe --tags --abbrev=0) | |
currentTag=$(git tag --contains) | |
if [ "$lastTag" != "$currentTag" ] | |
then | |
echo "New tag ${{ env.newVersion }}" | |
git tag ${{ env.newVersion }} | |
git push --tags | |
fi | |
- name: Expose as artifact | |
uses: actions/upload-artifact@v3.1.3 | |
with: | |
name: Build | |
path: src/UnityMVVM/build | |