diff --git a/.github/workflows/publish-alpha-release.yml b/.github/workflows/publish-alpha-release.yml new file mode 100644 index 0000000..a39377a --- /dev/null +++ b/.github/workflows/publish-alpha-release.yml @@ -0,0 +1,47 @@ +name: Tag and Publish Alpha + +on: + push: + branches: + - develop + +jobs: + build-bump-alpha-publish: + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo. + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x + - name: Get previous tag. + id: version + run: | + lastTag=`git tag -l --sort=-creatordate --format='%(refname:short)' | head -n 1` + echo "::set-output name=tag::$lastTag" + - name: Bump if alpha. + id: bump-with-alpha + uses: actions/github-script@v3 + with: + result-encoding: string + script: | + const incoming = "${{steps.version.outputs.tag}}" + console.log("Incoming Tag: " + incoming) + if(incoming.includes('alpha')) { + const oldNum = incoming.match(/alpha[.]*(\d+)/)[1] + const newNum = parseInt(oldNum)+1 + const newTag = incoming.replace(/alpha.*\d+/, `alpha.${newNum}`) + console.log("New Tag: " + newTag) + return newTag + } + else { + const splitLast = incoming.match(/(.*\.)(\d*)/) + const newTag =splitLast[1] + (parseInt(splitLast[2])+1)+'-alpha.0' + console.log("New Tag: " + newTag) + return newTag + } + - name: Set NuGet version from alpha. + run: echo "NUGET_VERSION=${{steps.bump-with-alpha.outputs.result}}" >> $GITHUB_ENV diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index 0020f56..a8af941 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -18,4 +18,3 @@ jobs: dotnet-version: 3.1.x - name: Set env run: echo "NUGET_VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV - - run: dotnet build -c release -p:Version=${{ env.NUGET_VERSION }} \ No newline at end of file